简体   繁体   English

link_to内的嵌套标签

[英]nest tag inside link_to

How to nest "strong" tag inside link_to helper 如何将“ strong”标签嵌套在link_to帮助器中

is this ok?(html_safe) 这样可以吗?(html_safe)

<li><%= link_to "Logged in as <strong>#{current_user.username}</strong>".html_safe, current_user %></li>

or mb there're other methods to do this. 或mb,还有其他方法可以做到这一点。

thanks! 谢谢!

There's special form of the link_to helper made for this use case: 为此用例制作了link_to帮助器的特殊形式:

<li>
  <%= link_to current_user do %>
    Logged in as <strong><%= current_user.username %></strong>
  <% end %>
</li>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM