在 link_to 调用中嵌入额外的 HTML [英] Embed additional HTML inside of link_to call
本文介绍了在 link_to 调用中嵌入额外的 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 link_to 调用中嵌入额外的 HTML?
How do I embed additional HTML inside of a link_to call?
这是我想要的结果:
<a href="/exercies/show/1"><i class="icon-show"></i>Show</a>
这是我的link_to电话
Here is my link_to call
<%= link_to "Show", exercise_path(exercise) %>
推荐答案
<%= link_to '<i class="icon-search"></i> Show'.html_safe, exercise_path(exercise), :class => 'btn btn-small' %>
.html_safe 是必需的,这样它就不会被转义.
.html_safe is required so that it is not escaped.
这篇关于在 link_to 调用中嵌入额外的 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文