问题
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.
回答1:
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')
回答2:
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>
来源:https://stackoverflow.com/questions/31326684/multiple-font-awesome-icons-as-rails-link