开发者

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

开发者 https://www.devze.com 2023-01-29 08:35 出处:网络
The following code: <%= link_to content_tag(:span, \'foo\'), :action => \'new\' %&g开发者_JS百科t;

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

精彩评论

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