Skip to main content

RUMWebTemplate

Trait RUMWebTemplate 

Source
pub trait RUMWebTemplate: Display + FastWritable {
    const SIZE_HINT: usize;

    // Required method
    fn render_into_with_values(
        &self,
        writer: &mut dyn Write,
        values: &dyn Values,
    ) -> Result<(), Error>;

    // Provided methods
    fn render(&self) -> Result<String, Error> { ... }
    fn render_with_values(&self, values: &dyn Values) -> Result<String, Error> { ... }
    fn render_into(&self, writer: &mut dyn Write) -> Result<(), Error> { ... }
    fn write_into(&self, writer: &mut dyn Write) -> Result<(), Error> { ... }
    fn write_into_with_values(
        &self,
        writer: &mut dyn Write,
        values: &dyn Values,
    ) -> Result<(), Error> { ... }
}
Expand description

Main Template trait; implementations are generally derived

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

§Rendering performance

When rendering a askama template, you should prefer the methods

over .to_string() or format!(). While .to_string() and format!() give you the same result, they generally perform much worse than askama’s own methods, because fmt::Write uses dynamic methods calls instead of monomorphised code. On average, expect .to_string() to be 100% to 200% slower than .render().

Required Associated Constants§

Source

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.

Required Methods§

Source

fn render_into_with_values( &self, writer: &mut dyn Write, values: &dyn Values, ) -> Result<(), Error>

Renders the template to the given writer fmt buffer with provided Values.

§Errors

It internally uses the core::fmt::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Provided Methods§

Source

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

Helper method which allocates a new String and renders into it.

§Errors

It internally uses the core::fmt::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Source

fn render_with_values(&self, values: &dyn Values) -> Result<String, Error>

Helper method which allocates a new String and renders into it with provided Values.

§Errors

It internally uses the core::fmt::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Source

fn render_into(&self, writer: &mut dyn Write) -> Result<(), Error>

Renders the template to the given writer fmt buffer.

§Errors

It internally uses the core::fmt::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Source

fn write_into(&self, writer: &mut dyn Write) -> Result<(), Error>

Renders the template to the given writer io buffer.

§Errors

It internally uses the std::io::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Source

fn write_into_with_values( &self, writer: &mut dyn Write, values: &dyn Values, ) -> Result<(), Error>

Renders the template to the given writer io buffer with provided Values.

§Errors

It internally uses the std::io::Write trait so it can fail and return Err for the same reasons. For other potential errors, please take a look at the Error enum variants documentation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Template for &T
where T: Template + ?Sized,

Source§

const SIZE_HINT: usize = T::SIZE_HINT

Source§

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

Source§

fn render_with_values(&self, values: &dyn Values) -> Result<String, Error>

Source§

fn render_into(&self, writer: &mut dyn Write) -> Result<(), Error>

Source§

fn render_into_with_values( &self, writer: &mut dyn Write, values: &dyn Values, ) -> Result<(), Error>

Source§

fn write_into(&self, writer: &mut dyn Write) -> Result<(), Error>

Source§

fn write_into_with_values( &self, writer: &mut dyn Write, values: &dyn Values, ) -> Result<(), Error>

Implementors§

Source§

impl Template for Anchor

Source§

const SIZE_HINT: usize = 222usize

Source§

impl Template for AppBody

Source§

const SIZE_HINT: usize = 187usize

Source§

impl Template for AppFooter

Source§

const SIZE_HINT: usize = 17usize

Source§

impl Template for AppNav

Source§

const SIZE_HINT: usize = 17usize

Source§

impl Template for AppShell

Source§

const SIZE_HINT: usize = 103usize

Source§

impl Template for AppShellHead

Source§

const SIZE_HINT: usize = 116usize

Source§

impl Template for Button

Source§

const SIZE_HINT: usize = 75usize

Source§

impl Template for CSS

Source§

const SIZE_HINT: usize = 263usize

Source§

impl Template for Card

Source§

const SIZE_HINT: usize = 127usize

Source§

impl Template for ContactCard

Source§

const SIZE_HINT: usize = 1222usize

Source§

impl Template for Container

Source§

const SIZE_HINT: usize = 171usize

Source§

impl Template for Details

Source§

const SIZE_HINT: usize = 186usize

Source§

impl Template for Div

Source§

const SIZE_HINT: usize = 132usize

Source§

impl Template for FlexRow

Source§

const SIZE_HINT: usize = 142usize

Source§

impl Template for FontAwesome

Source§

const SIZE_HINT: usize = 360usize

Source§

impl Template for FooterContents

Source§

const SIZE_HINT: usize = 111usize

Source§

impl Template for Form

Source§

const SIZE_HINT: usize = 1201usize

Source§

impl Template for FormNode

Source§

const SIZE_HINT: usize = 17usize

Source§

impl Template for FormattedLabel

Source§

const SIZE_HINT: usize = 178usize

Source§

impl Template for GotoButton

Source§

const SIZE_HINT: usize = 199usize

Source§

impl Template for HTMX

Source§

const SIZE_HINT: usize = 136usize

Source§

impl Template for Img

Source§

const SIZE_HINT: usize = 117usize

Source§

impl Template for InfoCard

Source§

const SIZE_HINT: usize = 461usize

Source§

impl Template for JobLoader

Source§

const SIZE_HINT: usize = 341usize

Source§

impl Template for Label

Source§

const SIZE_HINT: usize = 160usize

Source§

impl Template for List

Source§

const SIZE_HINT: usize = 518usize

Source§

impl Template for Loader

Source§

const SIZE_HINT: usize = 44usize

Source§

const SIZE_HINT: usize = 139usize

Source§

impl Template for Main

Source§

const SIZE_HINT: usize = 211usize

Source§

impl Template for Markdown

Source§

const SIZE_HINT: usize = 155usize

Source§

impl Template for Meta

Source§

const SIZE_HINT: usize = 366usize

Source§

impl Template for Nav

Source§

const SIZE_HINT: usize = 381usize

Source§

const SIZE_HINT: usize = 171usize

Source§

impl Template for PortraitCard

Source§

const SIZE_HINT: usize = 845usize

Source§

impl Template for Pre

Source§

const SIZE_HINT: usize = 154usize

Source§

impl Template for Sanitized

Source§

const SIZE_HINT: usize = 3usize

Source§

impl Template for Script

Source§

const SIZE_HINT: usize = 204usize

Source§

impl Template for Select

Source§

const SIZE_HINT: usize = 150usize

Source§

impl Template for Socials

Source§

const SIZE_HINT: usize = 295usize

Source§

impl Template for Spacer

Source§

const SIZE_HINT: usize = 147usize

Source§

impl Template for Summary

Source§

const SIZE_HINT: usize = 176usize

Source§

impl Template for TextCard

Source§

const SIZE_HINT: usize = 171usize

Source§

impl Template for Title

Source§

const SIZE_HINT: usize = 204usize

Source§

impl Template for YouTrack

Source§

const SIZE_HINT: usize = 286usize

Source§

impl<'a> Template for ContentViewer<'a>

Source§

const SIZE_HINT: usize = 930usize

Source§

impl<'a> Template for InputElement<'a>

Source§

const SIZE_HINT: usize = 44usize

Source§

impl<'a> Template for Link<'a>

Source§

const SIZE_HINT: usize = 179usize

Source§

impl<'a> Template for SelectElement<'a>

Source§

const SIZE_HINT: usize = 162usize

Source§

impl<T: RUMWebTemplate> Template for Footer<T>

Source§

const SIZE_HINT: usize = 195usize

Source§

impl<T: RUMWebTemplate> Template for Header<T>

Source§

const SIZE_HINT: usize = 183usize