[−][src]Trait sailfish::TemplateOnce
Template that can be rendered with consuming itself.
Required methods
pub fn render_once(self) -> RenderResult
[src]
Render the template and return the rendering result as RenderResult
This method never returns Err
, unless you explicitly return RenderError
inside templates
When you use render_once
method, total rendered size will be cached, and at
the next time, buffer will be pre-allocated based on the cached length.
If you don't want this behaviour, you can use render_once_to
method instead.
pub fn render_once_to(self, buf: &mut Buffer) -> Result<(), RenderError>
[src]
Render the template and append the result to buf
.
This method never returns Err
, unless you explicitly return RenderError
inside templates
use sailfish::TemplateOnce; use sailfish::runtime::Buffer; let tpl = HelloTemplate { messages: vec!["foo".to_string()] }; // custom pre-allocation let mut buffer = Buffer::with_capacity(100); tpl.render_once_to(&mut buffer).unwrap();