Sass with erb won't compile

后端 未结 2 1826
北恋
北恋 2020-12-14 12:16

In Rails, file file.css.sass.erb:

.class-name
    width: <%= \"10px\" %>

Is throwing the error:

Invalid          


        
相关标签:
2条回答
  • 2020-12-14 12:26

    You can use asset helpers if the erb is only for referencing assets:

    background-image: asset-url("rails.png")
    

    ...instead of...

    background-image: url("<%= image_path('rails.png') %>");
    
    0 讨论(0)
  • 2020-12-14 12:46

    This is indeed a problem with sass-rails, as discussed on GitHub.

    So this guy wrote this patch, which completely solves the problem.

    The Solution

    Add to Gemfile:

    gem "sass_rails_patch", "~> 0.0.1"
    

    then run bundle and you're good!

    0 讨论(0)
提交回复
热议问题