链轮 SASS 部分 ERB 延伸
我注意到,使用最新的 Rails 和 sprockets 版本(3.2.1 和 2.2.0),将 erb 文件扩展名添加到 sass 部分时似乎存在问题。
例如,如果 somestylefilename.css.sass 重命名为 somestylefilename.css.sass.erb 并且该文件包含使用 erb 的 sass 变量的声明,则可见:-
$background-colour: <%= '#fff' %> ;
一切都好。
但是,如果 sass 部分从 _sharedpartial.css.sass 重命名为 _sharedpartial.css.sass.erb,则无法识别相同的变量声明。
我不确定这是否是报告此行为的正确论坛,或者这是否是 sass、rails 或 sprockets 问题。
PS我知道资产管道通过预编译资产来提高效率,但我正在尝试编写一个主题控制器,它能够为站点选择默认颜色/布局方案,该方案随后将形成默认的预编译CSS资产生产。
最好的问候,
约翰·利克
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个
sass-rails
错误,如此处。我有同样的问题并发现解决方案是通过安装
sass-rais-path
。这使得 Rails 能够按预期工作 SASS + ERB。
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.
这听起来有点荒谬,但是您是否尝试过删除 .erb 扩展名?
通常你不必使用它,即使你使用 erb 标签。
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.