HAML multi-line attribute values

I am using KnockoutJS, which uses the json string in the data-bind attribute to indicate the binding information. I also like to use HAML.

This line 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() } }"} 

The solution is to use the :plain filter as follows (slightly different from the previous one): -

 :plain <div data-bind = "template: { name: 'twoLineResourceTemplate', foreach: resources, afterAdd: function(elem) { $(elem).hide().slideDown() } }"> </div> 

Is there an easier way to do this using HAML constructs instead of a filter?

I tried using the pipe symbol, but it does not work for HAML attributes.

Thanks!

+6
source share
2 answers

I tried pipe designation and this works for me:

 %ul#task-list.unstyled{"data-bind" => | "template: { " + | "name : 'taskHierarchy'," + | "foreach : contexts.children()," + | "afterAdd: function(elem) {" + | "$(elem).hide().slideDown()" + | "} }"} | 
+5
source
-1
source

Source: https://habr.com/ru/post/896392/


All Articles