Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed html in link text using Phoenix Framework?

I have a snippet that looks like this:

<%= link "<i class='fa fa-sign-out' aria-hidden='true'></i>", 
    to: auth_path(@conn, :delete), 
    method: :delete, class: "btn btn-danger" %>

It is a link. I would like to put a i element inside the text, so it shows an icon instead of text. However this escapes all the html characters and displays as text.

How do I make the i appear as html?

like image 248
Josh Petitt Avatar asked May 01 '16 13:05

Josh Petitt


1 Answers

Put the inner html in a do block:

<%= link to: auth_path(@conn, :delete), 
    method: :delete, class: "btn btn-danger" do %>
  <i class='fa fa-sign-out' aria-hidden='true'></i>
<% end %>

This is documented here.

like image 178
Dogbert Avatar answered Dec 04 '22 22:12

Dogbert