I've got some template HTML and JS files which are in the assets directory, structured like this:
app
- assets
- templates
- my_template.html
- javascripts
- application.js
- main.js.erb
Where application.js
contains the standard sprockets directive: //= require main
and main.js.erb
contains a reference to the path for my_template.html
:
main.js.erb
:
// Some code here ...
return {
pathToTemplate: "<%= asset_path 'my_template.html' %>"
}
// More code here ...
In development, this works great. main.js.erb
is evaluated to the following:
// Some code here ...
return {
pathToTemplate: "assets/my_template.html"
}
// More code here
In production, assets are precompiled (gzipped and whitespace removed), and a fingerprint is appended to the filename.
Production main.js.erb
should look like:
pathToTemplate: "assets/my_template-610dd79b5bb3c20d14b81baa891fc9dd.html"
but is instead the same as in development.
Does Sprockets need to be configured to also fingerprint HTML files? Perhaps it's a bug, because it's generating a
manifest file with fingerprinted paths, but asset_path is returning a non-fingerprinted path in main.js.erb
?
Thanks for your help.