sprockets sass partial erb extension

被刻印的时光 ゝ 提交于 2019-12-10 16:21:46

问题


I have noticed that with the latest rails and sprockets versions (3.2.1 & 2.2.0) there seems to be a problem when the erb file extension is added to a sass partial.

e.g. if somestylefilename.css.sass is renamed to somestylefilename.css.sass.erb and the file contains a declaration of a sass variable that uses erb, vis:-

$background-colour: <%= '#fff' %>;

all is ok.

However if a sass partial is renamed from say _sharedpartial.css.sass to _sharedpartial.css.sass.erb then the same variable declaration is not recognised.

I am not sure if this is the right forum to report this behaviour or if it is a sass, rails or sprockets problem.

P.S. I know that the asset pipeline targets efficiency through pre-compiled assets, but I am trying to write a theeme controller that is capable of selecting the default colour/layout scheme for a site which will subsequently form the default pre-compiled css asset in production.

Best regards,

John Leake


回答1:


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.




回答2:


This will sound a bit ridiculous, but have you tried to remove the .erb extension?

Normally you don't have to use it, even if you use erb tags.



来源:https://stackoverflow.com/questions/9268515/sprockets-sass-partial-erb-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!