Struct handlebars::RenderContext [−][src]
pub struct RenderContext<'reg, 'rc> { /* fields omitted */ }
Expand description
The context of a render call
This context stores information of a render and a writer where generated content is written to.
Implementations
impl<'reg: 'rc, 'rc> RenderContext<'reg, 'rc>
[src]
impl<'reg: 'rc, 'rc> RenderContext<'reg, 'rc>
[src]pub fn new(root_template: Option<&'reg String>) -> RenderContext<'reg, 'rc>
[src]
pub fn new(root_template: Option<&'reg String>) -> RenderContext<'reg, 'rc>
[src]Create a render context from a Write
pub fn push_block(&mut self, block: BlockContext<'reg>)
[src]
pub fn push_block(&mut self, block: BlockContext<'reg>)
[src]Push a block context into render context stack. This is typically called when you entering a block scope.
pub fn pop_block(&mut self)
[src]
pub fn pop_block(&mut self)
[src]Pop and drop current block context. This is typically called when leaving a block scope.
pub fn block(&self) -> Option<&BlockContext<'reg>>
[src]
pub fn block(&self) -> Option<&BlockContext<'reg>>
[src]Borrow a reference to current block context
pub fn block_mut(&mut self) -> Option<&mut BlockContext<'reg>>
[src]
pub fn block_mut(&mut self) -> Option<&mut BlockContext<'reg>>
[src]Borrow a mutable reference to current block context in order to modify some data.
pub fn set_context(&mut self, ctx: Context)
[src]
pub fn set_context(&mut self, ctx: Context)
[src]Set new context data into the render process. This is typically called in decorators where user can modify the data they were rendering.
pub fn evaluate(
&self,
context: &'rc Context,
relative_path: &str
) -> Result<ScopedJson<'reg, 'rc>, RenderError>
[src]
pub fn evaluate(
&self,
context: &'rc Context,
relative_path: &str
) -> Result<ScopedJson<'reg, 'rc>, RenderError>
[src]Evaluate a Json path in current scope.
Typically you don’t need to evaluate it by yourself. The Helper and Decorator API will provide your evaluated value of their parameters and hash data.
pub fn get_partial(&self, name: &str) -> Option<&Template>
[src]
pub fn get_partial(&self, name: &str) -> Option<&Template>
[src]Get registered partial in this render context
pub fn set_partial(&mut self, name: String, partial: &'reg Template)
[src]
pub fn set_partial(&mut self, name: String, partial: &'reg Template)
[src]Register a partial for this context
pub fn remove_partial(&mut self, name: &str)
[src]
pub fn remove_partial(&mut self, name: &str)
[src]Remove a registered partial
pub fn is_current_template(&self, p: &str) -> bool
[src]
pub fn is_current_template(&self, p: &str) -> bool
[src]Test if given template name is current template.
pub fn register_local_helper(
&mut self,
name: &str,
def: Box<dyn HelperDef + Send + Sync + 'rc>
)
[src]
pub fn register_local_helper(
&mut self,
name: &str,
def: Box<dyn HelperDef + Send + Sync + 'rc>
)
[src]Register a helper in this render context. This is a feature provided by Decorator where you can create temporary helpers.
pub fn unregister_local_helper(&mut self, name: &str)
[src]
pub fn unregister_local_helper(&mut self, name: &str)
[src]Remove a helper from render context
pub fn get_local_helper(
&self,
name: &str
) -> Option<Rc<dyn HelperDef + Send + Sync + 'rc>>
[src]
pub fn get_local_helper(
&self,
name: &str
) -> Option<Rc<dyn HelperDef + Send + Sync + 'rc>>
[src]Attempt to get a helper from current render context.
pub fn get_current_template_name(&self) -> Option<&'reg String>
[src]
pub fn get_current_template_name(&self) -> Option<&'reg String>
[src]Returns the current template name. Note that the name can be vary from root template when you are rendering from partials.
pub fn set_current_template_name(&mut self, name: Option<&'reg String>)
[src]
pub fn set_current_template_name(&mut self, name: Option<&'reg String>)
[src]Set the current template name.
pub fn get_root_template_name(&self) -> Option<&'reg String>
[src]
pub fn get_root_template_name(&self) -> Option<&'reg String>
[src]Get root template name if any.
This is the template name that you call render
from Handlebars
.
pub fn is_disable_escape(&self) -> bool
[src]
pub fn is_disable_escape(&self) -> bool
[src]Get the escape toggle
pub fn set_disable_escape(&mut self, disable: bool)
[src]
pub fn set_disable_escape(&mut self, disable: bool)
[src]Set the escape toggle. When toggle is on, escape_fn will be called when rendering.
Trait Implementations
impl<'reg, 'rc> Clone for RenderContext<'reg, 'rc>
[src]
impl<'reg, 'rc> Clone for RenderContext<'reg, 'rc>
[src]fn clone(&self) -> RenderContext<'reg, 'rc>
[src]
fn clone(&self) -> RenderContext<'reg, 'rc>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<'reg, 'rc> !RefUnwindSafe for RenderContext<'reg, 'rc>
impl<'reg, 'rc> !Send for RenderContext<'reg, 'rc>
impl<'reg, 'rc> !Sync for RenderContext<'reg, 'rc>
impl<'reg, 'rc> Unpin for RenderContext<'reg, 'rc>
impl<'reg, 'rc> !UnwindSafe for RenderContext<'reg, 'rc>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more