Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with HAML: Mixing text and other HTML tags

I am converting my ERB template to a HAML template.

<p>
   Welcome to <span><%= name1 %> </span>, <span> <%= name2 %></span> and <span><%= name3 %></span>.
</p>

This is what I have come up with

%p
  Welcome to 
  %span= name1
  ,
  %span= name2
  and
  %span= name3
  .

I have a feeling that there is much more elegant way to do this.

like image 754
Harish Shetty Avatar asked Feb 25 '10 21:02

Harish Shetty


1 Answers

There's no reason you shouldn't use inline HTML tags in your Haml document. See this post explaining why Haml isn't good for inline markup.

<p>
   Welcome to <span>#{name1}</span>, <span>#{name2}</span> and <span>#{name3}</span>.
</p>
like image 72
Natalie Weizenbaum Avatar answered Sep 27 '22 19:09

Natalie Weizenbaum