Trait stpl::TemplateExt [] [src]

pub trait TemplateExt: Template {
    fn render_dynamic_self(
        &self,
        data: &Self::Argument
    ) -> Result<Vec<u8>, DynamicError>
    where
        Self: Sized,
        Self::Argument: Serialize + for<'de> Deserialize<'de> + 'static
, { ... }
fn render_dynamic(
        &self,
        path: &Path,
        data: &Self::Argument
    ) -> Result<Vec<u8>, DynamicError>
    where
        Self: Sized,
        Self::Argument: Serialize + for<'de> Deserialize<'de> + 'static
, { ... }
fn render_static(&self, data: &Self::Argument) -> Result<Vec<u8>>
    where
        Self: Sized,
        Self::Argument: Serialize + for<'de> Deserialize<'de> + 'static
, { ... } }

Convinience methods for Template

Provided Methods

Call current binary file to handle the template

Make sure to put handle_dynamic at the very beginning of your binary if you want to use it.

See render_dynamic for more info.

This function will behave like render_static if STPL_PROD environment variable is enabled.

Call a template dynamically (with ability to update at runtime)

Make sure to put handle_dynamic at the very beginning of the code of program under path.

data type must be the same as template expects.

The template will evaluate in another process, so you can't rely on value of globals, and such, but otherwise it's transparent.

It works by serializing data and passing it to a child process. The child process is the current binary, with environment variable pointing to the right template. handle_dynamic will detect being a dynamic-template-child, deserialize data, render the template and write the output to stdout. This will be used as a transparent Template.

This function will behave like render_static if STPL_PROD environment variable is enabled.

Implementors