Phoenix.HTML.Link

Conveniences for working with links and URLs in HTML.

Source

Summary

link(text, opts)

Generates a link to the given URL

Functions

link(text, opts)

Generates a link to the given URL.

Examples

iex> link("hello", to: "/world")
{:safe, ~s(<a href="/world">hello</a>)}

iex> link("<hello>", to: "/world")
{:safe, ~s(<a href="/world"><hello></a>)}

iex> link("<hello>", to: "/world", class: "btn")
{:safe, ~s(<a class="btn" href="/world"><hello></a>)}

Options

  • :to - the page to link to. This option is required

  • :method - the method to use with the link. In case the method is not :get, the link is generated inside the form which sets the proper information. In order to submit the form, JavaScript must be enabled

All other options are forwarded to the underlying <a> tag.

Source