如何在eex中向功能链接(Phoenix.HTML.link)添加自定义HTML

问题描述 投票:0回答:2

我正在尝试向链接(Phoenix.HTML.link)添加自定义html

<%= link "<i class=\"fas fa-users\"></i> Login" to: "/login", class: "some class" %>

#But not working, result in this...
#HTML result:
<a class="some class" href="/login">&lt;i class="fas fa-users"&gt;&lt;/i&gt; Login</a>
html elixir phoenix-framework
2个回答
0
投票

功能link具有do... end

#Example of use
<%= link to: "url", class: "nav-link" do %>
    <i class="fas fa-users"></i> Login
<% end %>

这里是文档:https://hexdocs.pm/phoenix_html/Phoenix.HTML.Link.html


0
投票

使用Phoenix.HTML.raw/1

Phoenix.HTML.raw/1
© www.soinside.com 2019 - 2024. All rights reserved.