Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline HAML Links but with content

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

like image 708
rctneil Avatar asked Jun 06 '12 21:06

rctneil


People also ask

How do you add a link in the middle of a paragraph in HTML?

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.

How to write comments in Haml?

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 Haml in css?

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.


2 Answers

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
like image 123
Chris Barretto Avatar answered Nov 08 '22 20:11

Chris Barretto


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
like image 45
Dylan Markow Avatar answered Nov 08 '22 21:11

Dylan Markow