Skip to main content

Template

Struct Template 

Source
pub struct Template {
Show 17 fields pub name: String, pub description: Option<String>, pub source_dir: PathBuf, pub data: IndexMap<Id, Value>, pub interview: Vec<Node>, pub root: PathBuf, pub partials: Partials, pub files: Vec<FileRule>, pub inject: Vec<InjectRule>, pub ignore: GlobSet, pub static_files: GlobSet, pub hooks: Vec<HookNode>, pub messages: ApplyMessages, pub requires: Vec<Requirement>, pub interview_hook_nodes: Vec<Value>, pub top_hook_nodes: Vec<Value>, pub render_program: Vec<SourceEntry>, /* private fields */
}

Fields§

§name: String§description: Option<String>§source_dir: PathBuf§data: IndexMap<Id, Value>§interview: Vec<Node>§root: PathBuf§partials: Partials

The single include-confinement owner for this template’s file bodies, created once from the canonical root. It is retained so a source-tree body compiled during a later load step, and every stored files: body, resolves includes against the same root without a runtime loader.

§files: Vec<FileRule>§inject: Vec<InjectRule>§ignore: GlobSet§static_files: GlobSet§hooks: Vec<HookNode>§messages: ApplyMessages§requires: Vec<Requirement>

The programs that must be on PATH before the interview starts, in declaration order.

§interview_hook_nodes: Vec<Value>

Parsed, post-!include, pre-render interview hook node values, in interview order. The reviewable surface reads these, so any field — known or future — is covered without changing review code.

§top_hook_nodes: Vec<Value>

Parsed, post-!include, pre-render top-level hook node values, in list order.

§render_program: Vec<SourceEntry>

The retained, compiled source-tree render program, in deterministic walk order. Planning renders these; it does not reopen a Jinja source after admission.

Implementations§

Source§

impl Template

Source

pub fn admit_environment( &self, decision: EnvironmentDecision, source: &mut impl FixedEnvironmentSource, ) -> Result<EnvironmentSnapshot, EnvironmentAdmissionError>

Combines the immutable render-program analysis with one caller decision, capturing the closed five-value environment snapshot exactly once when granted and never otherwise.

Source

pub fn reserves_context(&self) -> bool

Whether this template reserves and exposes the seventeen context names.

Source§

impl Template

Source

pub fn has_question_id(&self, id: &Id) -> bool

Source§

impl Template

Source

pub fn load(folder: &Path) -> Result<Self, LoadError>

Loads a template in the current context mode: the seventeen reserved names collide with authored ids and resolve as available references.

Source

pub fn requirements(&self) -> Vec<Requirement>

The programs that must be on PATH before the interview starts, in order: the declared requires entries, then git when the template has a git question and does not declare git itself. The pre-interview check reads this list, not the field.

Source

pub fn load_legacy(folder: &Path) -> Result<Self, LoadError>

Loads a template in legacy staged mode: the seventeen names are neither reserved nor available, so a pre-context authored identifier is not turned into a collision while its old stage is completed.

Source§

impl Template

Source

pub fn git_question(&self) -> Option<&Id>

The id of the template’s git question, wherever it is in the interview. A template holds at most one.

Trait Implementations§

Source§

impl Debug for Template

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.