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!
I tried the pipe notation and it works for me:
%ul#task-list.unstyled{"data-bind" => |
"template: { " + |
"name : 'taskHierarchy'," + |
"foreach : contexts.children()," + |
"afterAdd: function(elem) {" + |
"$(elem).hide().slideDown()" + |
"} }"} |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With