将 link_to 与嵌入的 HTML 一起使用 [英] Using link_to with embedded HTML
本文介绍了将 link_to 与嵌入的 HTML 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Twitter 的 Bootstrap 内容,并且有以下 HTML:
I'm using Twitter's Bootstrap stuff and I have the following HTML:
<a class="btn" href="<%= user_path(@user) %>"><i class="icon-ok icon-white"></i> Do it@</a>
在 Rails 中执行此操作的最佳方法是什么?我想使用 <%= link_to 'Do it', user_path(@user) %>
但是 <i class="icon-ok icon-white"></i>
把我甩了?
What's the best way to do this in Rails? I'd like to use <%= link_to 'Do it', user_path(@user) %>
but the <i class="icon-ok icon-white"></i>
is throwing me off?
推荐答案
两种方式.要么:
<%= link_to user_path(@user) do %>
<i class="icon-ok icon-white"></i> Do it@
<% end %>
或者:
<%= link_to '<i class="icon-ok icon-white"></i> Do it@'.html_safe, user_path(@user) %>
这篇关于将 link_to 与嵌入的 HTML 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文