Reputation: 5454
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?
Upvotes: 18
Views: 20430
Reputation: 978
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.
Chris mentions that Haml is great for:
It is less great for when you have paragraphs of content you want to put in your document.
He suggests a few strategies to make it easier to embed text content in your Haml templates:
:plain
, :erb
:markdown
, etc. (Note :markdown
and other filters may require some Haml extensions to be installed.Upvotes: 5
Reputation: 8597
If you know your routes, then you can do this:
%p
I would like to make a #{link_to "link", foo_path} in my Rails app.
Pretty simple. Just wrap your Ruby syntax with #{}
.
Upvotes: 6
Reputation: 52326
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.
Upvotes: 16
Reputation: 13438
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.
Upvotes: 29