Sablon.Environment (sablon v0.4.3)

Copy Markdown View Source

Bundles the template being rendered with the user supplied context.

Operations receive an environment rather than a bare context so they can reach the document model - to register relationships or list definitions - while evaluating.

Summary

Functions

Returns a copy of the environment with context merged into it.

Builds an environment.

Sets the section properties, transforming them like a context.

Types

t()

@type t() :: %Sablon.Environment{
  context: map(),
  document: term(),
  section_properties: map(),
  template: term()
}

Functions

alter_context(env, context \\ %{})

@spec alter_context(t(), map() | keyword()) :: t()

Returns a copy of the environment with context merged into it.

new(source, context \\ %{})

@spec new(term(), map() | keyword()) :: t()

Builds an environment.

source may be a Sablon.Template, anything exposing a :document key, or a document model itself.

put_section_properties(env, properties)

@spec put_section_properties(t(), map() | keyword()) :: t()

Sets the section properties, transforming them like a context.