pub struct Env { /* private fields */ }
Expand description
Env is the top-level environment in which a Hatter template is evaluated and rendered.
Implementations§
Source§impl Env
impl Env
Sourcepub fn empty_args(&mut self) -> Args<'_>
pub fn empty_args(&mut self) -> Args<'_>
Create an empty Args struct, to call a helper function.
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Add a new scope to the stack, which becomes active.
Sourcepub fn var_exists(&self, key: &str) -> bool
pub fn var_exists(&self, key: &str) -> bool
Does a value exist in this or any parent scopes?
Sourcepub fn lookup(&self, key: &str) -> Option<Ref<'_, Value>>
pub fn lookup(&self, key: &str) -> Option<Ref<'_, Value>>
Find a value, looking first in the most recently pushed scope.
Sourcepub fn update<V: Into<Value>>(&self, key: &str, val: V)
pub fn update<V: Into<Value>>(&self, key: &str, val: V)
Set a value in a parent scope, or create it in the nearest.
Sourcepub fn print<V: Into<Value>>(&mut self, val: V)
pub fn print<V: Into<Value>>(&mut self, val: V)
Add something to our render buffer without a trailing line.
Sourcepub fn block(&mut self, stmts: &[Stmt]) -> Result<Value>
pub fn block(&mut self, stmts: &[Stmt]) -> Result<Value>
Evaluate a block of statements, returning the last one.
Sourcepub fn printed_block(&mut self, stmts: &[Stmt]) -> Result<Value>
pub fn printed_block(&mut self, stmts: &[Stmt]) -> Result<Value>
Evaluate a block of statements and print what each returns. “Outside of a tag, tags are printed. Inside of a tag, everything is printed.”
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Env
impl !RefUnwindSafe for Env
impl !Send for Env
impl !Sync for Env
impl Unpin for Env
impl !UnwindSafe for Env
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more