问题
li = link_to 'Account', '#account', data: { toggle: 'tab' }
I need span tags around 'Account'.
回答1:
li = link_to content_tag(:span, 'Account'), '#account', data: { toggle: 'tab' }
http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-tag
回答2:
You can also use a block if you find that you have more complex code inside the link text than just a span tag:
li = link_to '#account', data: {toggle: 'tab'} do
span
= "Account"
回答3:
li = link_to "<span>Account</span>".html_safe, '#account', data: { toggle: 'tab' }
来源:https://stackoverflow.com/questions/15987566/how-do-i-wrap-span-tags-in-a-link-to-in-slim