Haml syntax: split a line to a couple of rows

后端 未结 5 1309
慢半拍i
慢半拍i 2021-01-03 20:15

I use HAML in my rails project for my html templates. I would like to figure out if its possible to divide a very long line and make it a couple of rows:

%a.         


        
5条回答
  •  被撕碎了的回忆
    2021-01-03 20:54

    I just came accross this question, I was having the same issue but the selected answer didn't help me. So I'm just building upon Mikhail's answer. If you have very long attributes that are not separated by commas (say you're using something like angularjs), you can split it on several lines by adding + | at the end of each line (including the last line in this multiline block, which is the tricky part).

    Just like this :

    %select{ ng: { model: "my_model_name",
                 options: "myitem as myitem.formattedName for myitem in container.item_list() | " + |
                          "without: another_list.item_list()" }}                                    |
    

    You can read about this in HAML documentation.

提交回复
热议问题