Otera.State (otera v0.1.0)

Copy Markdown View Source

The mutable state of a render, for the Python objects that templates change: namespace() objects and the last value of loop.changed().

Values are immutable in Elixir, so run/1 keeps this state in the process dictionary for the length of a render, and restores the previous state after it, so that a render inside a custom filter does not see the state of the outer render.

Summary

Functions

Returns the value for key, or default.

Sets the value for key.

Runs fun with an empty state.

Functions

get(key, default \\ nil)

@spec get(term(), term()) :: term()

Returns the value for key, or default.

put(key, value)

@spec put(term(), term()) :: :ok

Sets the value for key.

run(fun)

@spec run((-> result)) :: result when result: term()

Runs fun with an empty state.