RenderState

Struct RenderState 

Source
pub struct RenderState<'a> {
    pub loader: Option<&'a (dyn TemplateLoader + Send + Sync)>,
    pub stack: Vec<String>,
    pub macro_scopes: Vec<HashMap<String, MacroDef>>,
    pub macro_namespaces: HashMap<String, HashMap<String, MacroDef>>,
    pub macro_namespace_values: HashMap<String, HashMap<String, Value>>,
    pub block_chains: Option<HashMap<String, Vec<Vec<Node>>>>,
    pub super_context: Option<(String, usize)>,
    pub caller_stack: Vec<CallerFrame>,
    pub cyclers: Vec<CyclerState>,
    pub joiners: Vec<JoinerState>,
    pub rng: SmallRng,
    /* private fields */
}
Expand description

Per-render state: optional loader, include cycle stack, macro scopes, and block inheritance for extends.

Fields§

§loader: Option<&'a (dyn TemplateLoader + Send + Sync)>§stack: Vec<String>§macro_scopes: Vec<HashMap<String, MacroDef>>§macro_namespaces: HashMap<String, HashMap<String, MacroDef>>

{% import "x" as ns %} — macros callable as ns.macro_name().

§macro_namespace_values: HashMap<String, HashMap<String, Value>>

Top-level {% set %} exports from each import … as ns namespace (ns.name): single- and multi-target = forms (same value per target) and block {% set x %}…{% endset %}, evaluated in source order. Also used with macro_namespaces for resolving ns.*.

§block_chains: Option<HashMap<String, Vec<Vec<Node>>>>

Per-block inheritance: innermost template first (child → parent → …) for {{ super() }}.

§super_context: Option<(String, usize)>

When rendering a block layer, Some((block_name, layer_index)) for super() resolution.

§caller_stack: Vec<CallerFrame>

Innermost {% call %} frame for caller() / caller(args…) inside macro execution.

§cyclers: Vec<CyclerState>

Stateful cycler(...) instances (index matches handle object).

§joiners: Vec<JoinerState>

Stateful joiner(...) instances.

§rng: SmallRng

PRNG for | random (seed from Environment::random_seed when set).

Implementations§

Source§

impl<'a> RenderState<'a>

Source

pub fn new( loader: Option<&'a (dyn TemplateLoader + Send + Sync)>, rng_seed: Option<u64>, ) -> Self

Source

pub fn push_template(&mut self, name: &str) -> Result<()>

Source

pub fn pop_template(&mut self)

Source

pub fn push_macros(&mut self, defs: HashMap<String, MacroDef>)

Source

pub fn pop_macros(&mut self)

Source

pub fn lookup_macro(&self, name: &str) -> Option<&MacroDef>

Source

pub fn lookup_namespaced_macro( &self, ns: &str, macro_name: &str, ) -> Option<&MacroDef>

Source

pub fn lookup_namespaced_value(&self, ns: &str, name: &str) -> Option<&Value>

Auto Trait Implementations§

§

impl<'a> Freeze for RenderState<'a>

§

impl<'a> !RefUnwindSafe for RenderState<'a>

§

impl<'a> Send for RenderState<'a>

§

impl<'a> Sync for RenderState<'a>

§

impl<'a> Unpin for RenderState<'a>

§

impl<'a> !UnwindSafe for RenderState<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V