What if only 2 mode in one file
Like when I use web-mode in rails, there're only 2 mode in .js.erb file, javascript and ruby, there's no <script>...</script> in these kind of files. so how to make web-mode render javascript code?
I do not understand. Could you explain it an other Way please.
And could you post an example on gist please.
<% if true %>
// This is javascript code
alert('aa');
<% end %>
Save this as test.js.erb.
In rails .js.erb file only contain javascript and ruby.

You can see that ruby code highlight while javascript not.
Ok, understood. I ll work on this
could you try updating the var web-mode-content-types in web-mode.el please
(defvar web-mode-content-types
'(("css" . "\\.css\\'\\|\\.css\\.erb\\'")
("javascript" . "\\.js\\'\\|\\.js\\.erb\\'")
("json" . "\\.\\(json\\|jsonld\\)\\'")
("html" . "."))
"content types")
Works, but there're problems.
Before add the code:

After:

The ruby tag <% %> is not highlight and the color is a little different.
Do web-mode have a major mode? normally we use html-mode as major mode, when find the code between <script>...</script>, highlight it with js-mode and find code between <% .. %>, highlight it with ruby-mode, other's use html-mode.
Do web-mode behave like this?
@eorza web-mode.el is autonomous ... no other mode is used. I'll look at your bug.
the last github provides compatibility with *.js.erb and *.css.erb The indentation issue described above is not a bug. If the content-type is js ... the indentation is ok