在使用 link_to 方法生成的链接正文中获取嵌入 HTML 的最佳方法是什么?
我基本上想要以下内容:
<a href="##">This is a <strong>link</strong></a>
我一直在尝试按照Rails and the <span> tag中的建议解决这个问题。但没有运气。我的代码如下所示:
item_helper.rb
def picture_filter
#...Some other code up here
text = "Show items with " + content_tag(:strong, 'pictures')
link_to text, {:pics => true}, :class => 'highlight'
end
item_view.html.erb
#...
<%=raw picture_filter %>
#...
最佳答案
试试这个方法
<%= link_to(raw("a <strong>strong</strong> link"),{:pics => true},{ :class => 'highlight'}) %>
关于ruby-on-rails - Rails 中 link_to body 中嵌入的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5317951/