Skip to content

Commit

Permalink
docs: update the component example of Phoenix integration
Browse files Browse the repository at this point in the history
  • Loading branch information
c4710n committed Jan 11, 2024
1 parent fed75c1 commit ac00c08
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions lib/cozy_svg.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,26 @@ defmodule CozySVG do
### `svg/1` component
An example:
use Phoenix.Component
attr :key, :string, required: true, doc: "The key for SVG file."
attr :rest, :global, doc: "Additional attributes to add to the <svg> tag."
def svg(assigns) do
~H\"\"\"
<%= raw DemoWeb.SVG.render(@key, @rest) %>
\"\"\"
end
An example module:
defmodule DemoWebSvgComponents do
defmodule CompiledSVG do
use CozySVG.QuickWrapper, root: "assets/svg"
end
use Phoenix.Component
import Phoenix.HTML, only: [raw: 1]
attr :key, :string, required: true, doc: "The key for SVG file."
attr :rest, :global, doc: "Additional attributes to add to the <svg> tag."
def svg(assigns) do
~H\"\"\"
<%= raw(CompiledSVG.render(@key, @rest)) %>
\"\"\"
end
end
### Live reloading
Enable live reloading by telling Phoenix to watch the SVG directory:
Expand Down

0 comments on commit ac00c08

Please sign in to comment.