Node

Enum Node 

Source
pub enum Node {
Show 19 variants Root(Vec<Node>), Text(Arc<str>), Output(Vec<Expr>), If { branches: Vec<IfBranch>, }, For { vars: ForVars, iter: Expr, body: Vec<Node>, else_body: Option<Vec<Node>>, }, Set { targets: Vec<String>, value: Option<Expr>, body: Option<Vec<Node>>, }, Include { template: Expr, ignore_missing: bool, with_context: Option<bool>, }, Switch { expr: Expr, cases: Vec<SwitchCase>, default_body: Option<Vec<Node>>, }, Extends { parent: Expr, }, Block { name: String, body: Vec<Node>, }, MacroDef(MacroDef), Import { template: Expr, alias: String, with_context: Option<bool>, }, FromImport { template: Expr, names: Vec<(String, Option<String>)>, with_context: Option<bool>, }, FilterBlock { name: String, args: Vec<Expr>, body: Vec<Node>, }, CallBlock { caller_params: Vec<MacroParam>, callee: Expr, body: Vec<Node>, }, AsyncEach { vars: ForVars, iter: Expr, body: Vec<Node>, else_body: Option<Vec<Node>>, }, AsyncAll { vars: ForVars, iter: Expr, body: Vec<Node>, else_body: Option<Vec<Node>>, }, IfAsync { branches: Vec<IfBranch>, }, ExtensionTag { extension_name: String, tag: String, args: String, body: Option<Vec<Node>>, },
}
Expand description

Template structure produced by the parser.

  • Node::Root: sequence of top-level fragments (text + outputs).
  • Node::Text: literal characters from the template.
  • Node::Output: one or more Expr values to evaluate and concatenate (filters etc. are future work).

Variants§

§

Root(Vec<Node>)

Container for sibling template fragments.

§

Text(Arc<str>)

Raw text between (or outside) template tags (shared across clones of the AST).

§

Output(Vec<Expr>)

Content inside {{}} after expression parsing.

§

If

{% if %}, optional {% elif %}, optional {% else %}, {% endif %}.

Fields

§branches: Vec<IfBranch>
§

For

{% for var in iter %} … {% endfor %} (optional {% else %} before endfor).

Fields

§vars: ForVars
§iter: Expr
§body: Vec<Node>
§else_body: Option<Vec<Node>>
§

Set

{% set a = expr %}, {% set a, b = expr %}, or {% set a %}…{% endset %}.

Fields

§targets: Vec<String>
§value: Option<Expr>
§body: Option<Vec<Node>>
§

Include

{% include expr %} with optional ignore missing — template name from expression.

with_context: None / Some(true) — current frame stack; Some(false) — isolated root context (template globals only; matches Jinja without context / Nunjucks-style isolation).

Fields

§template: Expr
§ignore_missing: bool
§with_context: Option<bool>
§

Switch

{% switch expr %}{% case c %}…{% default %}…{% endswitch %}.

Fields

§expr: Expr
§default_body: Option<Vec<Node>>
§

Extends

{% extends expr %} — template name from any expression (e.g. quoted string or variable); must appear before meaningful child content.

Fields

§parent: Expr
§

Block

{% block name %}…{% endblock %} — default body when used in a base layout.

Fields

§name: String
§body: Vec<Node>
§

MacroDef(MacroDef)

{% macro name(a, b) %}…{% endmacro %} — emits no output; registers a macro for the current template.

§

Import

{% import expr as alias %} — loads a template and exposes its top-level macros under alias (alias.macro()).

Fields

§template: Expr
§alias: String
§with_context: Option<bool>

Some(true) = with context (parent context when evaluating top-level {% set %} and macro bodies); Some(false) or omitted = isolated (Nunjucks default).

§

FromImport

{% from expr import a, b as c %} — imports named macros into the current macro scope.

Fields

§template: Expr
§names: Vec<(String, Option<String>)>

(exported_name, alias) where alias is the local name (same as exported if None).

§with_context: Option<bool>
§

FilterBlock

{% filter name %}…{% endfilter %} — render body to a string, then apply a builtin filter.

Fields

§name: String
§args: Vec<Expr>
§body: Vec<Node>
§

CallBlock

{% call macro(args) %}…{% endcall %} — macro may invoke caller() to render this body. Optional {% call(a, b) m() %}caller(x, y) passes arguments into the call body scope.

Fields

§caller_params: Vec<MacroParam>
§callee: Expr
§body: Vec<Node>
§

AsyncEach

{% asyncEach var in iter %} … {% endeach %} — sequential async iteration. Each iteration body is awaited sequentially; async filters/globals within the body can suspend.

Fields

§vars: ForVars
§iter: Expr
§body: Vec<Node>
§else_body: Option<Vec<Node>>
§

AsyncAll

{% asyncAll var in iter %} … {% endall %} — parallel async iteration. All iteration bodies are rendered concurrently; results are concatenated in iteration order.

Fields

§vars: ForVars
§iter: Expr
§body: Vec<Node>
§else_body: Option<Vec<Node>>
§

IfAsync

{% ifAsync cond %} … {% endif %} — async condition evaluation.

Fields

§branches: Vec<IfBranch>
§

ExtensionTag

Custom extension tag (addExtension / Environment::register_extension).

Fields

§extension_name: String
§tag: String

Opening tag name (e.g. echo).

§args: String

Raw source after the tag name until %} (trimmed).

§body: Option<Vec<Node>>

Block body when the extension declares an end tag.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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