pub struct ForgeContext { /* private fields */ }Expand description
A typed context passed to Engine::render().
Wraps tera::Context and provides a builder-style API.
Implementations§
Source§impl ForgeContext
impl ForgeContext
pub fn new() -> Self
Sourcepub fn insert<T: Serialize + ?Sized>(self, key: &str, value: &T) -> Self
pub fn insert<T: Serialize + ?Sized>(self, key: &str, value: &T) -> Self
Insert a serializable value (builder style, consumes self).
Sourcepub fn insert_mut<T: Serialize + ?Sized>(&mut self, key: &str, value: &T)
pub fn insert_mut<T: Serialize + ?Sized>(&mut self, key: &str, value: &T)
Insert a serializable value (mutable style, for use in loops).
Sourcepub fn slot(self, name: &str, content: &str) -> Self
pub fn slot(self, name: &str, content: &str) -> Self
Register a named slot with content to be injected into the template.
Slots use thread-local storage and are populated just before the render
call inside Engine::render(). This method stages them on the context
so that Engine can apply them before delegating to Tera.
Sourcepub fn provide(self, key: &str, value: &str) -> Self
pub fn provide(self, key: &str, value: &str) -> Self
Register a provided value to be made available via inject(key=...) in templates.
Values are stored under __provides__ and applied to the thread-local store
at render time by Engine::render().
Sourcepub fn from_serialize<T: Serialize>(data: &T) -> Result<Self>
pub fn from_serialize<T: Serialize>(data: &T) -> Result<Self>
Build a context from a serializable struct.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ForgeContext
impl RefUnwindSafe for ForgeContext
impl Send for ForgeContext
impl Sync for ForgeContext
impl Unpin for ForgeContext
impl UnsafeUnpin for ForgeContext
impl UnwindSafe for ForgeContext
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