HAML 中的多行属性值
我正在使用 KnockoutJS,它使用 data-bind 属性中的 json 字符串来指示绑定信息。我也喜欢使用 HAML。
该字符串很快就会变得很长,例如:-
%ul#task-list.unstyled{"data-bind" => "template: { name : 'taskHierarchy', foreach : contexts.children(), afterAdd: function(elem) { $(elem).hide().slideDown() } }"}
解决方案是使用 :plain
过滤器,如下所示(与上面略有不同):-
:plain
<div data-bind = "template: {
name: 'twoLineResourceTemplate',
foreach: resources,
afterAdd: function(elem) { $(elem).hide().slideDown() }
}">
</div>
是否有更简洁的方法来使用 HAML 构造来执行此操作过滤器的?
我尝试过使用管道字符,但它似乎不适用于 HAML 属性。
谢谢!
I am using KnockoutJS which uses a json string within the data-bind
attribute to indicate binding information. I also like using HAML.
This string can quickly become quite long, for example:-
%ul#task-list.unstyled{"data-bind" => "template: { name : 'taskHierarchy', foreach : contexts.children(), afterAdd: function(elem) { $(elem).hide().slideDown() } }"}
A solution is to use the :plain
filter as follows (slightly different from above):-
:plain
<div data-bind = "template: {
name: 'twoLineResourceTemplate',
foreach: resources,
afterAdd: function(elem) { $(elem).hide().slideDown() }
}">
</div>
Is there a neater way to do this using HAML constructs instead of the filter?
I have tried using the pipe character but it does not seem to work for HAML attributes.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了管道符号,它对我有用:
I tried the pipe notation and it works for me:
您可以在 KnockoutJS 和 Unobtrusive JavaScript 上尝试这篇文章
You could try this post on KnockoutJS and Unobtrusive JavaScript