views:

115

answers:

1

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.

+4  A: 

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>
nex3
The `<p>` tag can still be a Haml `%p`, can't it?
Mike Woodhouse
I was aware of HAML's ability to embed HTML. I needed validation for this approach. The article that you linked is quite good. Still mixing two Ruby embedding syntax is yucky.
KandadaBoggu