How can I do something like this in HAML (within Rails app such that it matters)?
<li><a href="#" title="Meet the Team"><strong>Team <em>16 members</em></strong></a></li>
Edit: how also to do it with link_to
and a route of pages_team
?
To make a hyperlink in an HTML page, use the <a> and </a> tags, which are the tags used to define the links. The <a> tag indicates where the hyperlink starts and the </a> tag indicates where it ends. Whatever text gets added inside these tags, will work as a hyperlink.
What is it? Haml (HTML abstraction markup language) is based on one primary principle: markup should be beautiful. It's not just beauty for beauty's sake either; Haml accelerates and simplifies template creation down to veritable haiku.
The basic method would look like this ...
%li
%a{ :href => "#", :title => "Meet the Team" }
%strong
Team
%em 16 members
Or using the new hash syntax ...
%li
%a{ href: "#", title: "Meet the Team" }
%strong
Team
%em 16 members
%li= link_to raw('<strong>Team <em>16 members</em></strong>'), pages_team, :title => 'Meet the Team'
or
%li= link_to content_tag(:strong, raw("Team #{content_tag(:em, '16 members)}")), pages_team, :title => 'Meet the Team
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With