0

I've got a link_to that looks like this

<%= link_to site.name, site %>

I want to add a font icon from bootstrap into the anchor text, but when I try to use raw() for that, I can't figure out the syntax for including the site.name hook.

This is what I'm trying:

<%= link_to raw("<i class="icon-hdd"></i> site.name"), site %>

That's not working. How do I change that line to make it work?

2 Answers 2

3

Have you tried the do syntax?

<%= link_to site do %>
  <i class="icon-hdd"> </i> <%= site.name%>
<% end %>
Sign up to request clarification or add additional context in comments.

Comments

1

You need to interpolate site_name into the string.

<%= link_to raw("<i class='icon-hdd'></i> #{site.name}"), site %>

1 Comment

Also be careful with the quotes - you had double quotes inside double quotes which is not valid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.