使用 :sass 过滤器和 :css
我们目前正在制作一个小部件,它需要一些默认声明的样式(小部件 html 由 javasacript 包含,以及样式标签中的默认 css),但问题是我无法“链接”haml 过滤器。
我想做的是添加一个内部样式表以及小部件,如下所示:
<style type="text/css">
p {color: #f00;}
</style>
<div id="widget-goes-here">
<p>etc</p>
</div>
我们正在使用 haml,所以我尝试使用 sass 过滤器来完成它:
:sass
p
:color #f00
#widget-goes-here
%p etc
遗憾的是,它只是生成了一个带有 ap 的 div 加上字面上生成的 css 代码顶部:
p {color: #f00;}
paragraph here
然后我尝试使用 haml 的 :css 过滤器将内容包含在样式标签中(理论上它应该将段落文本颜色变为红色):
:css
:sass
p
:color #f00
#widget-goes-here
%p etc
但这也失败了,它确实生成了样式标签,但随后它只是包含了单词:sass p :color #f00 其中(它没有解析 sass 代码)
我们确实将其更改为
:css
p {color: #f00}
并且效果很好,但我仍然计划在 sass 中进行样式设置(而不是普通的旧 css)方法来做到这一点?
We are currently making a widget that requires some default declared styles along with it(widget html is included by javasacript, along with the default css in style tags) but the problem is i can't "chain" haml filters.
What I'm trying to do is to add an internal stylesheet along with the widget like so:
<style type="text/css">
p {color: #f00;}
</style>
<div id="widget-goes-here">
<p>etc</p>
</div>
We are using haml so I tried doing it with the sass filter:
:sass
p
:color #f00
#widget-goes-here
%p etc
sadly, it just generated a div with a p plus the generated css code literally on top:
p {color: #f00;}
paragraph here
I then tried using the :css filter of haml to enclose the thing in style tags(theoretically it should then turn the paragraph text color to red):
:css
:sass
p
:color #f00
#widget-goes-here
%p etc
But this also failed, it did generated style tags but then it just enclosed the words :sass p :color #f00 in it(it didn't parse the sass code)
We did change it to
:css
p {color: #f00}
and it worked out fine, but I still plan on doing the styling in sass(instead of plain old css) is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还在 haml 组中发布了此内容,这是回复:
您不能嵌套过滤器。
你想要这样的 sass:
哦,好吧,如果它是嵌套的,它可能会更漂亮。
Also posted this in the haml groups and this was the reply:
You can't nest filters.
you want this for sass:
Oh well, it could have been prettier if it were nested.