Reputation: 16734
I am trying to put a link_to
between (
and )
by doing this:
= div_for review do
= link_to review.title, review_path(review)
(
= link_to review.user.email, user_path(review.user)
)
The outcome is not what I want because it puts spaces between the parenthesis and the link text, so it looks like:
link1 ( link2 )
But I want it to look like:
link1 (link2)
How do I do that using haml?
Upvotes: 1
Views: 4953
Reputation: 17735
Use a string with inline ruby:
= link_to review.title, review_path(review)
=raw "(#{link_to review.user.email, user_path(review.user)})"
The raw is for Rails 3 (and higher) only.
Upvotes: 3
Reputation: 110
I recently fount interesting thing about haml
== - Ruby interpolated string
%h1== (#{link-to review.user.email, user_path(review.user)})
is like
%h1= raw "(#{link_to review.user.email, user_path(review.user)})"
Upvotes: 5
Reputation: 124469
= link_to review.title, review_path(review)
= surround '(', ')' do
= link_to review.user.email, user_path(review.user)
Alternatively, you could put your link in a span
tag and tell Haml to eat the whitespace:
(
%span>= link_to review.user.email, user_path(review.user)
)
Upvotes: 4