Otera.Template (otera v0.2.0)

Copy Markdown View Source

A parsed template. Otera.parse/2 makes it, and Otera.render/3 renders it many times without parsing it again.

name is the name of the template, nil for a template from a string without the :name option. options holds the options of Otera.parse/2, which also apply to each render. scope is the root scope from Otera.Scope, blocks holds the blocks of the template by name, and extends? is true when the template has an extends tag.

Summary

Functions

Loads the template name with the :loader of opts and parses it with opts. Raises Otera.Error with the kind :template_not_found, or Otera.SyntaxError.

Types

t()

@type t() :: %Otera.Template{
  ast: list(),
  blocks: %{required(String.t()) => tuple()},
  extends?: boolean(),
  name: String.t() | nil,
  options: keyword(),
  scope: Otera.Scope.t(),
  source: String.t()
}

Functions

load(name, opts)

@spec load(String.t(), keyword()) :: t()

Loads the template name with the :loader of opts and parses it with opts. Raises Otera.Error with the kind :template_not_found, or Otera.SyntaxError.

A template that the loader gives as an Otera.Template without a name gets the name name. With the :cache option, the template comes from that Otera.Cache while it is fresh.