如何HAML混合Ruby代碼和文字標記與Haml的
<%= some_ruby_code %>:
# OR
<%= some_ruby_code %><br />
寫這ERB我可以:
=some_ruby_code + ":"
# and
=some_ruby_code
%br
,但我不想在這裏串聯,我想將它內聯寫:
(=some_ruby_code):
# and
(=some_ruby_code)%br
如何HAML混合Ruby代碼和文字標記與Haml的
<%= some_ruby_code %>:
# OR
<%= some_ruby_code %><br />
寫這ERB我可以:
=some_ruby_code + ":"
# and
=some_ruby_code
%br
,但我不想在這裏串聯,我想將它內聯寫:
(=some_ruby_code):
# and
(=some_ruby_code)%br
=some_ruby_code + ":"
-# and
=some_ruby_code + "<br/>"
編輯1:
我不確定你到底在找什麼。你想要其中之一嗎?
==#{some_ruby_code}:
-# and
==#{some_ruby_code}<br/>
或
==#{some_ruby_code}:
-# and
=some_ruby_code
%br
有沒有辦法在HAML使用%br
除非是上線的第一個非空白的事情,據我所知。
試着這麼做
= some_ruby_code
:
= some_ruby_code
%br
注意,即使結腸是一個換行,它不是投入在HTML換行符。
或者,
#{some_ruby_code}:
#{some_ruby_code}
%br
HAML可以做內聯紅寶石插補#{}。
內嵌的Ruby插值 - '#{...}'效果最好。 –
您正在使用的第一行連接而不是標記我想使用haml''br br – fl00r
'==#{}'就是這樣,謝謝〜! – fl00r
如果我想讓Ruby代碼遵循內聯文本,我該怎麼辦?也許像下面這樣''一些內聯文本#{som_ruby_code}' – kalu