pub trait TeraConnExt {
    // Required methods
    fn assign(self, key: &str, value: impl Serialize) -> Self;
    fn render(self, template: &str) -> Self;
    fn tera(&self) -> &Tera;
    fn context_mut(&mut self) -> &mut Context;
    fn context(&self) -> &Context;
}
Expand description

Extends trillium::Conn with tera template-rendering functionality.

Required Methods§

source

fn assign(self, key: &str, value: impl Serialize) -> Self

Adds a key-value pair to the assigns Context, where the key is a &str and the value is any Serialize type.

source

fn render(self, template: &str) -> Self

Uses the accumulated assigns context to render the template by registered name to the conn body and return the conn. Halts and sets a 200 status on successful render. Must be run downsequence of the TeraHandler, and will panic if the TeraHandler has not already been called.

source

fn tera(&self) -> &Tera

Retrieves a reference to the Tera instance. Must be called downsequence of the TeraHandler, and will panic if the TeraHandler has not already been called.

source

fn context_mut(&mut self) -> &mut Context

retrieves a reference to the tera assigns context. must be run downsequence of the TeraHandler, and will panic if the TeraHandler has not already been called.

source

fn context(&self) -> &Context

Retrieves a reference to the tera assigns context. Must be run downsequence of the TeraHandler, and will panic if the TeraHandler has not already been called.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TeraConnExt for Conn

source§

fn assign(self, key: &str, value: impl Serialize) -> Self

source§

fn tera(&self) -> &Tera

source§

fn context_mut(&mut self) -> &mut Context

source§

fn context(&self) -> &Context

source§

fn render(self, template_name: &str) -> Self

Implementors§