How can I use Ruby/Rails variables inside Sass?

2019-01-05 05:11发布

问题:

Is there a way to use variables from my Ruby application inside a Sass file?

回答1:

You can add .erb extention to your .sass file and then add your variables just like in regular .erb file:

<%= APP_CONFIG[:yourkey] %>

More information:

  • http://guides.rubyonrails.org/asset_pipeline.html#preprocessing
  • http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
  • http://rwilcox.tumblr.com/post/9038701675/sass-variables-and-the-rails-3-1-asset-pipeline


标签: