Beacon.Template.HEEx (Beacon v0.5.0)

View Source

Handles loading and compilation of HEEx templates.

Summary

Functions

compile(site, path, template, file \\ nil)

Compile template returning its AST.

compile!(site, path, template, file \\ nil)

render(site, template, assigns \\ %{})

@spec render(Beacon.Types.Site.t(), String.t(), map()) :: String.t()

Renders the HEEx template with assigns.

Use only to render isolated templates

This function should not be used to render Page Templates, its purpose is only to render isolated pieces of templates.

Example

iex> Beacon.Template.HEEx.render(:my_site, ~S|<.link patch="/contact" replace={true}><%= @text %></.link>|, %{text: "Book Meeting"})
"<a href="/contact" data-phx-link="patch" data-phx-link-state="replace">Book Meeting</a>"