crispychicken
crispychicken

Reputation: 2662

how include span in link_to erb

I want to write this HTML in ERB:

<a href="/" id="logo">One<span id="red>Two</span></a>

How do I include the span?

<%= link_to "ONETWO", root_path, id: "logo" %>

Upvotes: 0

Views: 1515

Answers (2)

zeantsoi
zeantsoi

Reputation: 26193

Inline:

<%= link_to(raw('One<span id="red">Two</span>'), root_path, id: "logo")  %>

Upvotes: 3

m_x
m_x

Reputation: 12554

just use the block form of this helper :

<%= link_to root_path, id: :logo do %>
  One<span id="red>Two</span>
<% end %>

Other helpers support this form, like content_for.

Upvotes: 5

Related Questions