I have not been able to understand why one should add extension .erb to an ordinary .js file in the app/assets folder? This is how I came to wonder this:
In my app, I want no more than one http request spent for a js file to be included in the body of the HTML page/DOM. This I can do by adding js filenames (with inclusion of lines like) into the application.js manifest file:
//= require jquery
//= require directory_name
//= require jQuery_plugins/carousel
//= require jQuery_plugins/word-editor
//= require jQuery_plugins/abc_something
and so on.
Now I have a long list of javascripts for the entire rails app, and I want the manifest file to output (to include) javascripts in a page-specific way. To manage this, I attempted to add conditions like:
if params[:controller] == "my_controller" && params[:action] == "index"
//= require jQuery_plugins/carousel
Also I converted application.js to application.js.erb file to see if that worked. But no! It did not work. Manifest will output everything that comes its way. Looks like a question was posed for a similar problem on SOF, but solutions given in the answers there seem very old-school and rather unclean traditional way.
Where-do-you-put-your-page-specific-javascript-code
So what is, really, the use of converting js into js.erb file? And can I manage page-specific output purely on the basis a "js manifest" file?