简体   繁体   中英

content_for button Rails Helper

I'm trying to translate a simple button into content_tag's for a Helper:

My Helper:

html = link_to disconnect_path(social: provider.downcase), class: "btn btn-#{provider.downcase} btn-block btn-social" do
  content_tag :i, 'Verified', class: "fa fa-#{provider.downcase}"
end

The button i need:

<a class="btn btn-block btn-social btn-facebook">
  <i class="fa fa-facebook"></i> Sign in with Facebook
</a>

The helper gets the 'Verified' inside the i tags ->

<i class="test">Verified</i>

but instead it should be outside ->

<i class="test"></i> Verified

Can anyone help me out setting this up ?

Than move the title text outside of the i tag:

link_to(disconnect_path(social: provider.downcase), class: "btn btn-#{provider.downcase} btn-block btn-social") do
  content_tag(:i, '', class: "fa fa-#{provider.downcase}") + 'Verified'
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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