Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

hyperlink - link_to image_tag with inner text or html in rails

I want to output the following with Ruby on Rails link_to and image_tag methods:

<a href="#">Lorem Ipsum <img src="/images/menu-arrow-down.gif"></a>

What would be a good way in Rails?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use blocks as an alternative to the string interpolation with correct usage html_safe. For example:

<%= link_to '#' do %>
  Lorem Ipsum <%= image_tag('/images/menu-arrow-down.gif') %>
<% end %>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...