开发者

Mixing Ruby code and literal markup with Haml

开发者 https://www.devze.com 2023-03-29 13:56 出处:网络
How to write this ERB in HAML <%= some_ruby_code %>: # OR <%= some_ruby_code %><br /> I can:

How to write this ERB in HAML

<%= some_ruby_code %>:
# OR
<%= some_ruby_code %><br />

I can:

=some_ruby_co开发者_开发技巧de + ":"
# and
=some_ruby_code
%br

but I don't want concatenating here and I want to write it inline:

(=some_ruby_code):
# and
(=some_ruby_code)%br


=some_ruby_code + ":"
-# and
=some_ruby_code + "<br/>"

EDIT 1:

I'm not sure exactly what you are looking for. Would you like one of these?

==#{some_ruby_code}:
-# and
==#{some_ruby_code}<br/>

or

==#{some_ruby_code}:
-# and
=some_ruby_code
%br

There is no way to use %br in HAML unless it is the first non-whitespace thing on the line, as far as I know.


Try something like

= some_ruby_code
:

= some_ruby_code
%br

Note that even though the colon is on a newline, it isn't put into a newline in the HTML.

Or,

#{some_ruby_code}:
#{some_ruby_code}
%br

HAML can do inline Ruby interpolation with #{}.

0

精彩评论

暂无评论...
验证码 换一张
取 消