Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing Ruby code and literal markup with Haml

How to write this ERB in HAML

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

I can:

=some_ruby_code + ":"
# 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
like image 662
fl00r Avatar asked Aug 19 '11 15:08

fl00r


1 Answers

=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.

like image 163
David Grayson Avatar answered Oct 29 '22 10:10

David Grayson