rctneil
rctneil

Reputation: 7210

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

Upvotes: 12

Views: 12626

Answers (2)

Chris Barretto
Chris Barretto

Reputation: 9529

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

Upvotes: 30

Dylan Markow
Dylan Markow

Reputation: 124429

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

Upvotes: 2

Related Questions