The operations a template can perform.
Statements are built once from the merge fields found in a document part and then evaluated in order, each mutating the document in place.
Summary
Functions
Evaluates a statement against env, mutating the document.
Renders the first clause whose condition holds and clears the rest.
The value a clause's truthiness is decided by: its expression, optionally through a predicate.
The truthiness rules sablon uses: nil, false and empty lists are falsy.
Functions
@spec evaluate( struct(), Sablon.Environment.t() ) :: any()
Evaluates a statement against env, mutating the document.
Dispatch is by struct module, so an application can define its own statement
by giving the module an evaluate/2 function - see
Sablon.Processor.Document.register_field_handler/2 for how to produce one.
@spec render_conditions([map()], term(), Sablon.Environment.t(), (map(), Sablon.Environment.t() -> term())) :: any()
Renders the first clause whose condition holds and clears the rest.
resolve turns a clause into the value its truthiness is decided by; the
default reads the clause expression from the context and applies its
predicate. Passing a different one is how a custom conditional - comparison
operators, say - reuses the rest of this logic.
@spec resolve_condition(map(), Sablon.Environment.t()) :: term()
The value a clause's truthiness is decided by: its expression, optionally through a predicate.
The truthiness rules sablon uses: nil, false and empty lists are falsy.