Inline HAML Links but with content
11,761
Solution 1
If you want to do a 1 liner:
%p= "Hello, this is my text. #{link_to 'Link here', '#'} This is more text".html_safe
Multiline
%p
Hello, this is my text.
= link_to 'Link here', '#'
This is more text
Solution 2
You should just be able to do this:
%p Hello, this is my text. <a href="#">Link here</a> This is more text
This would work too:
%p
Hello, this is my test.
%a{:href => '#'} Link here
This is more text
Author by
rctneil
Updated on June 21, 2022Comments
-
rctneil about 2 years
I am trying to output something along the lines of
<p>Hello, this is my text. <a href="#">Link here</a> This is more text</p>
but using HAML
How would this be done? I keep finding examples but none that show how to do it but with plain text either side of the link?
Neil
-
rctneil about 12 yearsJust tried this: %p= "This is my text #{ link_to "See ALL albums", albums_path }" But that just outputs This is my text <a href="/albums">See ALL albums</a> How would I solve this?
-
Chris Barretto about 12 yearsadd html_safe to the end (changed in the answer)
-
Chris Barretto about 12 years%p= "This is my text #{ link_to "See ALL albums", albums_path }".html_safe