Trait askama::Template

source ·
pub trait Template: Display {
    const EXTENSION: Option<&'static str>;
    const SIZE_HINT: usize;
    const MIME_TYPE: &'static str;

    // Required method
    fn render_into(&self, writer: &mut (impl Write + ?Sized)) -> Result<()>;

    // Provided methods
    fn render(&self) -> Result<String> { ... }
    fn write_into(&self, writer: &mut (impl Write + ?Sized)) -> Result<()> { ... }
Expand description

Main Template trait; implementations are generally derived

If you need an object-safe template, use DynTemplate.

Required Associated Constants§


const EXTENSION: Option<&'static str>

The template’s extension, if provided


const SIZE_HINT: usize

Provides a rough estimate of the expanded length of the rendered template. Larger values result in higher memory usage but fewer reallocations. Smaller values result in the opposite. This value only affects render. It does not take effect when calling render_into, write_into, the fmt::Display implementation, or the blanket ToString::to_string implementation.


const MIME_TYPE: &'static str

The MIME type (Content-Type) of the data that gets rendered by this Template

Required Methods§


fn render_into(&self, writer: &mut (impl Write + ?Sized)) -> Result<()>

Renders the template to the given writer fmt buffer

Provided Methods§


fn render(&self) -> Result<String>

Helper method which allocates a new String and renders into it


fn write_into(&self, writer: &mut (impl Write + ?Sized)) -> Result<()>

Renders the template to the given writer io buffer

Object Safety§

This trait is not object safe.