开发者

How can I add additional tags in a link in rails?

The following code:

<%= link_to content_tag(:span, 'foo'), :action => 'new' %&g开发者_JS百科t;

Renders the link like this:

<a href="/new"><span>foo</span></a>

I would like to add the bold tags after the ending span tag like this:

<a href="/new"><span>foo</span><b></b></a>

How can I add the tags after the ending span tag?


You can pass link_to a block instead of a string param:

<%= link_to :action => 'new' do %>
  <span>foo</span>
  <strong></strong>
<% end %>

Note: If you're on Rails 2.3 or earlier, use:

<% link_to :action => 'new' do %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜