template-fragments

Crates.iotemplate-fragments
lib.rstemplate-fragments
version0.2.0
sourcesrc
created_at2023-06-11 17:35:39.363218
updated_at2023-06-11 17:35:39.363218
descriptiontemplate-fragments for jinja-like engines
homepage
repositoryhttps://github.com/chmp/template-fragments-rs
max_upload_size
id887499
size54,255
Christopher Prohm (chmp)

documentation

README

template-fragments for jinja-like engines

Usage with minijinja (see also examples/minijinja.rs):

use template_fragments::{join_path, split_templates};

let mut source = minijinja::Source::new();

for (path, template) in  [
    ("index.html", include_str!("templates/index.html")),
    ("users.html", include_str!("templates/users.html")),
] {
    for (fragment_name, template_fragment) in split_templates(template)? {
        source.add_template(join_path(path, &fragment_name), &template_fragment)?;
    }
}
Commit count: 12

cargo fmt