I want to use an Emoji, e.g. Trash-Emoji (HTML Entity: & #x1f5d1;) inside link_to, like:
<%= link_to "🗑", tape_path(tape.id), method: :delete, data: { confirm: 'Are you sure to delete?' }, class: 'btn btn-default btn-sm btn-warning' %>
But no Trash-Emoji itself is showing. I also tried "& #x1f5d1;", #{& #x1f5d1;}, & #x1f5d1; but syntac errors were shown.
I want to try to write without using any additional GEM at first. Does someone know how should be written?
html_safe
and raw
are not very flexible approaches when you want to make a really customized link
It is more elegant to use block
where you can do A LOT:
<%= link_to root_path do %>
Homepage
<div class="fa fa-flag"></div>
🗑
<%= User.count %>
<% end %>
https://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to
Your case:
<%= link_to root_path, method: :delete, data: { confirm: 'Are you sure to delete?' }, class: 'btn btn-default btn-sm btn-warning' do %>
🗑
<% end %>