How to add awesome font to link_to method on rails using haml?

I am trying to change my layout to add link_to to the drop down list.

previous code:

  %li.divider
  %li
    %a{:href => "#"}
      %i.fa.fa-user-profile
      Add new user

i edited as follows:

 %li.divider
 %li
   = link_to '<i class="fa fa-user-profile"></i> Add new user'.html_safe, new_user_path

And everything looks fine, but fa-user-profile is 0px x 0px and it is invisible. What have I done wrong?

HTML output:

enter image description here

+4
source share
2 answers

link_tohas a “block” form that accepts custom internal markup:

= link_to new_user_path do
  %i.fa.fa-user-profile
  Add new user

: FontAwesome CSS, font-family ( fa) content ( ). , , CSS.

, FontAwesome . font-awesome-sass README , .

+4

raw()

= link_to raw('<i class="fa fa-user-profile"></i> Add new user'), new_user_path
0

Source: https://habr.com/ru/post/1612720/


All Articles