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
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.
HTML Comments: /The forward slash can also wrap indented sections of code. For example: / %p This doesn't render... %div %h1 Because it's commented out!
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.
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
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
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