logo
Expand description

black_marlin is a simple, small, and extremely fast template engine for Rust. Before reading this reference, I recommend reading User guide.

This crate contains utilities for rendering black_marlin templates. If you want to use black_marlin templates, import black_marlin-macros crate and use derive macro #[derive(TemplateOnce)] or #[derive(Template)].

In most cases you don’t need to care about the runtime module in this crate, but if you want to render custom data inside templates, you must implement runtime::Render trait for that type.

use black_marlin::TemplateOnce;

#[derive(TemplateOnce)]
#[template(path = "hello.stpl")]
struct HelloTemplate {
    messages: Vec<String>
}

fn main() {
    let ctx = HelloTemplate {
        messages: vec!["foo".to_string(), "bar".to_string()]
    };

    println!("{}", ctx.render_once().unwrap());
}

Modules

BlackMarlin runtime

Enums

The error type which is returned from template function

Traits

Work in Progress

Template that can be rendered with consuming itself.

Type Definitions

Result type returned from TemplateOnce::render_once method

Derive Macros