In Rails, file file.css.sass.erb
:
.class-name
width: <%= "10px" %>
Is throwing the error:
Invalid CSS after "": expected expression (e.g. 1px, bold), was "<%= "10px" %>"
Isn't it supposed to work?
Update 1
Still struggling with it, but I found that if I change it to SCSS syntax (filename and code), still it causes a very similar error.
Invalid CSS after " width: ": expected expression (e.g. 1px, bold), was "<%= "10px" %>;"
Although, if I remove the scss
extension, leaving the CSS similar syntax with the filename file.css.erb
, Rails does compile as expected.
Yet considering I'm forgetting something very obvious, I'm also considering this could be a gem conflict with sass-rails
, or a bug, or something. After all, the code is working without SASS extensions.
Update 2
Just found other 4 unanswered questions on this same issue on:
- scss.erb ruby code not
executing
- Assets not being run though the .erb
preprocessor
- Rails erb preprocessing not happening in development
mode
- sprockets sass partial erb
extension.
Some of them ended up working around the problem by changing approaches. The ERB issue on SASS files remained untouched.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…