Mit Hilfe der (absichtlich) seltsame mehrzeiligen Format für HAML, würde Ich mag die folgenden Zeilen in meiner Vorlage haben:Mehrere mehrzeiligen HAML Blöcke
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
-# and
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
Allerdings können sie nicht laufen gegen oder sie werden als ein einziger mehrzeiliger Block gelesen.
-# This fails:
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
Und mit einem Zeilenumbruch trennt, interessanterweise funktioniert nicht besser:
-# This fails, too:
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
Die einzige funktionierende Lösung, die ich gefunden habe, ist eine Leerzeile von Ruby-Code zwischen auszuführen. Das sieht wirklich hässlich aus.
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
-
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
Gibt es etwas Schöneres?
** Update: ** Die Rohre sind nicht in der neuesten Version von HAML erforderlich Also bleib nicht hängen, wenn du gerade über diese Frage stolperst;) – Matchu