Astral.Template (Astral v0.2.0)

Copy Markdown View Source

Renders .astral templates with HEEx semantics.

A .astral file is a small single-file template: an optional leading Elixir setup block delimited by ---, followed by HEEx markup. Component files under the configured components directory become local HEEx function components, so components/formatted_date.astral is called as <.formatted_date />.

Summary

Functions

Return the template source currently being rendered in this process.

Render template source with project components and assigns.

Render a .astral file with project components and assigns.

Render a Markdown file as HEEx with project components and assigns.

Evaluate a .astral setup block and return its Elixir binding.

Return true when a path points to an Astral template.

Functions

current_source()

@spec current_source() :: String.t() | nil

Return the template source currently being rendered in this process.

render(source, assigns, config)

@spec render(Astral.Template.Source.t(), map() | keyword(), Astral.Config.t()) ::
  {:ok, String.t()} | {:error, term()}

Render template source with project components and assigns.

render_file(path, assigns, config)

@spec render_file(String.t(), map() | keyword(), Astral.Config.t()) ::
  {:ok, String.t()} | {:error, term()}

Render a .astral file with project components and assigns.

render_markdown_file(path, assigns, config)

@spec render_markdown_file(String.t(), map() | keyword(), Astral.Config.t()) ::
  {:ok, String.t()} | {:error, term()}

Render a Markdown file as HEEx with project components and assigns.

setup_binding_file(path, assigns, config)

@spec setup_binding_file(String.t(), map() | keyword(), Astral.Config.t()) ::
  {:ok, keyword()} | {:error, term()}

Evaluate a .astral setup block and return its Elixir binding.

template?(path)

@spec template?(String.t()) :: boolean()

Return true when a path points to an Astral template.