user3277633
user3277633

Reputation: 1923

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.

Upvotes: 0

Views: 534

Answers (2)

cmoran92
cmoran92

Reputation: 290

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>

Upvotes: 1

Mark Swardstrom
Mark Swardstrom

Reputation: 18080

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')

Upvotes: 1

Related Questions