View Source CozySVG.QuickWrapper (cozy_svg v0.2.2)
Creates a wrapper module quickly.
This is a high-level abstraction of the basic API provided by
CozySVG
.
Usage
Assuming the structure of SVG files is like this:
assets/svg
├── logo.svg
└── misc
├── header.svg
└── footer.svg
Creates a wrapper module:
defmodule DemoWeb.SVG do
use CozySVG.QuickWrapper, root: "assets/svg"
end
Then, the generated functions can be used like this:
DemoWeb.SVG.render("logo")
DemoWeb.SVG.render("misc/header", class: "w-6 h-auto mr-2")
DemoWeb.SVG.render("misc/footer", class: "w-6 h-auto mr-2")
DemoWeb.SVG.render!("logo")
DemoWeb.SVG.render!("misc/header", class: "w-6 h-auto mr-2")
DemoWeb.SVG.render!("misc/footer", class: "w-6 h-auto mr-2")