How to add icon to button_tag using HAML?

I'm having trouble trying to make a play button using HAML.

 =button_tag clue_path(@question), class: "btn btn-lg glyphicon glyphicon-play" 

Html results

<button><icon class:"glyphicon glyphicon-play">/question/1/clue</i></button>

It should be

<button><icon class: "glyphicon glyphicon-play"></i></button>

I am very close to solving it. What am I missing?

+4
source share
2 answers

If you want to put the icon inside the button using Bootstrap and HAML, try:

%button.btn.btn-lg.btn-default
  %i.glyphicon.glyphicon-play
+5
source

The doenst button tag has an href attribute.

you use the tag style as a button.

I also recommend that you use "fontawesome" instead of glyphicon. integration is very simple, just add a gem and say bootstrap to use FA.

: https://fortawesome.imtqy.com/Font-Awesome/icons/

=link_to clue_path(@question), class: "btn btn-lg" do 
  %i.glyphicon.glyphicon-play

-awesome gem,

=link_to clue_path(@question), class: "btn btn-lg" do 
  =icon "glyphicon-play"

or

=link_to icon("glyphicon-play"), clue_path(@question), class: "btn btn-lg"
+1

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


All Articles