phoenix_inline_svg v0.2.0 PhoenixInlineSvg.Helpers
The module that adds the view helpers to fetch and render SVG files into safe HTML.
In order to get best use out of this this module
should be imported in the quoted view
def of the web/web.ex
.
def view do
quote do
import PhoenixInlineSvg.Helpers
end
end
Summary
Functions
Sends the contents of the SVG file name
in the directory
Functions
Sends the contents of the SVG file name
in the directory.
Returns a safe HTML string with the contents of the SVG file
wrapped in an i
HTML element with classes.
Examples
Using only the default collection (generic):
<%= svg_image(@conn, "home") %>
Will result in output of:
<i class="generic-svgs generic-home-svg">
<svg>...</svg>
</i>
Expects the SVG to be loaded from:
priv/static/svg/
Which is configurable through the config option:
config :phoenix_inline_svg, dir: "some/other/dir"
Using a collection:
<%= svg_image(@conn, "user", "fontawesome") %>
Will result in the output:
<i class="fontawesome-svgs fontawesome-home-svg">
<svg>...</svg>
</i>