which refers to a line in a .js.erb file ending in -%>.
The ending hyphen was added to eliminate the line break in .html.erb
files.
But when I remove the hyphen, the error goes away. The last sentence
ofsection’2.2.1
CSS and ERB’ in http://guides.rubyonrails.org/asset_pipeline.htmlThe Asset Pipeline — Ruby on Rails Guides
says ‘Note that the closing tag cannot be of the style -%>.’ Does anyone
know why adding the dash before %> in .js.erb (and apparently in
.css.erb)
files causes the rails precompiler to fail?
which refers to a line in a .js.erb file ending in -%>.
The ending hyphen was added to eliminate the line break in .html.erb
files.
But when I remove the hyphen, the error goes away. The last sentence
ofsection’2.2.1
CSS and ERB’ in
says ‘Note that the closing tag cannot be of the style -%>.’ Does anyone
know why adding the dash before %> in .js.erb (and apparently in
.css.erb)
files causes the rails precompiler to fail?
Because using -%> causes a syntax error, unexpected tSTRING_BEG to
occur.
<<>>
In my quick test case I got a syntax error, unexpected ‘)’
…rbout.concat(( ‘Hello World’ -).to_s); _erbout.concat "");.…
Notice that the dash is still there trying to be concatenated in.
I don’t really know exactly why, but it’s obvious you cannot use -%> in
js.erb or css.erb, so don’t do it and your code wont fail.
It’s because -%> needs to know how to remove whitespace from within the
file itself, parsing & reading the content outside the replacement
content. I don’t know for sure but I’ll bet the explanation is simply
that this is too complicated in these pipeline files because whitespace
works differently.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.