Trait THelper

Source
pub trait THelper: Sized {
    // Required methods
    fn push_helper(
        self,
        fname: &str,
        f: fn(&[Value]) -> Result<Value, String>,
    ) -> Self;
    fn render_me(&self, c: &Context) -> Result<String, String>;

    // Provided methods
    fn q_render<V: Into<Value>>(&self, v: V) -> Result<String, String> { ... }
    fn with_math(self) -> Self { ... }
    fn with_range(self) -> Self { ... }
    fn with_select(self) -> Self { ... }
    fn with_string(self) -> Self { ... }
    fn with_svg(self) -> Self { ... }
    fn with_all(self) -> Self { ... }
    fn with_defaults(self) -> Self { ... }
    fn with_exec(self) -> Self { ... }
}
Expand description

This trait exists to give methods to the Template object directly. It is not intended to be applied to anything else. By “use“ing this trait, you gain the ability to write “with_svg()” or “with_all() and gain the appropriate helpers for your template q_render is also included to make it slightly easier to render a template. Rather than having to perform Context::from().unwrap() yourself

Required Methods§

Source

fn push_helper( self, fname: &str, f: fn(&[Value]) -> Result<Value, String>, ) -> Self

Source

fn render_me(&self, c: &Context) -> Result<String, String>

Provided Methods§

Source

fn q_render<V: Into<Value>>(&self, v: V) -> Result<String, String>

Source

fn with_math(self) -> Self

Source

fn with_range(self) -> Self

Source

fn with_select(self) -> Self

Source

fn with_string(self) -> Self

Source

fn with_svg(self) -> Self

Source

fn with_all(self) -> Self

👎Deprecated since 0.1.2: please use with_defaults instead
Source

fn with_defaults(self) -> Self

Source

fn with_exec(self) -> Self

This is not included in the “with_defaults” option to make sure you know you have added it, as it would be dangerous to use in any web facing programs

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl THelper for Template

Source§

fn push_helper( self, fname: &str, f: fn(&[Value]) -> Result<Value, String>, ) -> Self

Source§

fn render_me(&self, c: &Context) -> Result<String, String>

Implementors§