pub struct TemplateRenderer<'a, T: Serialize> { /* private fields */ }Expand description
Go Template Renderer
Implementations§
Source§impl<'a, T: Serialize> TemplateRenderer<'a, T>
impl<'a, T: Serialize> TemplateRenderer<'a, T>
Sourcepub fn new(template_content: &'a str, data: &'a T) -> Self
pub fn new(template_content: &'a str, data: &'a T) -> Self
Creates a new template renderer.
§Arguments
template_content- Go template content as a string slice.data- Data to be injected into the template, must implementSerialize.
Sourcepub fn escape_html(self, escape: bool) -> Self
pub fn escape_html(self, escape: bool) -> Self
Sets whether to escape HTML in the output.
Defaults to false.
Sourcepub fn use_missing_key_zero(self, use_zero: bool) -> Self
pub fn use_missing_key_zero(self, use_zero: bool) -> Self
Sets whether to treat missing keys as zero values.
Go Template’s missingkey=zero option.
Source§impl<'a, T: Serialize> TemplateRenderer<'a, T>
impl<'a, T: Serialize> TemplateRenderer<'a, T>
Sourcepub fn render_quick(
template: &'a str,
data: &'a T,
) -> Result<String, RenderError>
pub fn render_quick( template: &'a str, data: &'a T, ) -> Result<String, RenderError>
快速渲染模板的便捷方法
Sourcepub fn render_html(
template: &'a str,
data: &'a T,
) -> Result<String, RenderError>
pub fn render_html( template: &'a str, data: &'a T, ) -> Result<String, RenderError>
渲染HTML转义的模板
Auto Trait Implementations§
impl<'a, T> Freeze for TemplateRenderer<'a, T>
impl<'a, T> RefUnwindSafe for TemplateRenderer<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for TemplateRenderer<'a, T>where
T: Sync,
impl<'a, T> Sync for TemplateRenderer<'a, T>where
T: Sync,
impl<'a, T> Unpin for TemplateRenderer<'a, T>
impl<'a, T> UnwindSafe for TemplateRenderer<'a, T>where
T: RefUnwindSafe,
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