Rails erb preprocessing not happening in developme

2019-08-20 03:18发布

For whatever reason, this first attempt at dynamic styling gets me a Sass::SyntaxError on the line below. It looks like the erb is not being pre-processed.

/* app/assets/stylesheets/variables.css.scss.erb */

$headerHeight: <%= '15px' %>;

It's in development mode. Any idea what could cause this?

Here are my configuration options relating to assets in case that helps:

# Application
config.assets.enabled = true
config.assets.initialize_on_precompile = true
config.assets.version = '1.1'

# Development
config.assets.compress = false
config.assets.debug = false

2条回答
成全新的幸福
2楼-- · 2019-08-20 03:24

This is a sass-rails error, as discussed here.

I had the same question and found out that the solution is by installing sass-rais-path.

This gets Rails to work SASS + ERB as expected. No need to use quotes.

查看更多
SAY GOODBYE
3楼-- · 2019-08-20 03:33

The scss needs quotes around the 15px part. So you will need to make it:

$headerHeight: "<%= '15px' %>";
查看更多
登录 后发表回答