0

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 Answers 2

0

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

$headerHeight: "<%= '15px' %>";
3
  • Seems to work, but you definitely do not need quotes for assigning the variable to a constant, i.e. this works $headerHeight: 35px; so its interesting erb needs quotes
    – AJcodez
    Nov 14, 2012 at 18:39
  • 1
    Sorry, to confirm, that won't evaluate. Check your css, it will just show '"<%= '15px' %>"' wherever you use that variable.
    – user419017
    Nov 15, 2012 at 12:35
  • 1
    I'm having this exact same issue here. Could you find a way to get ERB working on SCSS stylesheets? Jan 13, 2013 at 14:50
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.