views:

78

answers:

3

How do I create this:

<p>
  I would like to make a <a href="foo.html">link</a> in my Rails app.
</p>

with HAML?

+3  A: 

1.

%p
  I would like to make a
  %a
    link
  in my Rails app.

2.

%p
  I would like to make a <a href="#">link</a> in my Rails app.
floatless
Thanks! I must need more coffee. It was the return after the %p that I wasn't seeing.
Eric the Red
+4  A: 

The "pure" HAML way:

%p
  I would like to make a 
  %a{:href => "foo.html"} link
  in my Rails app.

Using the Rails link_to helper:

%p
  I would like to make a 
  =link_to "link", "foo.html"
  in my Rails app.
Mike Woodhouse
For the record, I was originally using link_to :-) Thanks for the help!
Eric the Red
+1  A: 

I recommend reading Chris Eppstein's post "Haml Sucks for Content", and using something like Markdown or Textile to handle inline markup. I'm a big fan of Haml for document structure and a simple link in a paragraph is simple enough, but Haml starts to get out of control pretty fast.

Jeremy Weiskotten
I like that way of putting it: Haml is great for structure.
Chuck