简体   繁体   中英

multiple font awesome icons as rails link

I have the following font-awesome line that is a clickable link

%p.add_stuff= link_to(content_tag(:i, nil, class: "fa fa-plus"), new_journey_trip_path(@journey))

In addition to fa-plus, I'd like to add another font-awesome plus icon (so it appears something like + + ). How do I achieve this?

I've tried calling fa-plus two times, as well as making two content_tag, but neither seems to work.

Have you tried something like this?

%p.add_stuff= link_to(new_journey_trip_path(@journey)) do
  %i.fa.fa-plus
  %i.fa.fa-plus

You can also remove whitespace if needed:

%p.add_stuff= link_to(new_journey_trip_path(@journey)) do
  %i.fa.fa-plus>
  %i.fa.fa-plus>

with link_to, you can nest the contents

%p.add_stuff
  = link_to new(journey_trip_path(@journey)) do
    = content_tag(:i, nil, class: "fa fa-plus")
    = content_tag(:i, nil, class: "fa fa-plus")

or

%p.add_stuff
   = link_to new(journey_trip_path(@journey)) do
     %i.fa.fa-plus
     %i.fa.fa-plus

or, you may have the fa_icon method available...

%p.add_stuff
  = link_to new(journey_trip_path(@journey)) do
    = fa_icon('plus')
    = fa_icon('plus')

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