serum v1.0.0 Serum.Template.Compiler

This module handles template loading and preprocessing.

Link to this section Summary

Functions

Compiles a list of template files.

Compiles the given EEx string.

Link to this section Types

Link to this type

options()
options() :: [type: Serum.Template.template_type(), includes: templates()]

Link to this type

templates()
templates() :: %{optional(binary()) => Serum.Template.t()}

Link to this section Functions

Link to this function

compile_files(files, options)
compile_files([Serum.File.t()], options()) :: Serum.Result.t(map())

Compiles a list of template files.

A code that requires and imports Serum.Template.Helpers is injected before the input data.

The files parameter is a list of Serum.File structs representing loaded template files. That is, for each item of this list, the value of :in_data must not be nil.

The options parameter is a keyword list of additional options controlling the behavior of this function. The available options are:

  • type: Either :template or :include, defaults to :template.
  • includes: A map where the key of each item is the name of the includable template, and the value associated with the key is a Serum.Template struct, which is an already compiled Serum template.
Link to this function

compile_string(string, options)
compile_string(binary(), options()) ::
  {:ok, Macro.t()} | {:ct_error, binary(), integer()}

Compiles the given EEx string.