Crate template_nest

source ·
Expand description

Template engine for Rust.

For more details on the idea behind Template::Nest read:


More examples in examples/ directory.

Place these files in templates directory: templates/00-simple-page.html:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Simple Page</title>
    <p>A fairly simple page to test the performance of Template::Nest.</p>
    <p><!--% variable %--></p>
    <!--% simple_component %-->


<p><!--% variable %--></p>

Those templates can be used in a template hash which is passed to TemplateNest::render to render a page:

use template_nest::TemplateNest;
use template_nest::{filling, Filling};
use std::collections::HashMap;

let nest = TemplateNest::new("templates").unwrap();
let simple_page = filling!(
    "TEMPLATE": "00-simple-page",
    "variable": "Simple Variable",
    "simple_component":  {
        "variable": "Simple Variable in Simple Component"
println!("{}", nest.render(&simple_page).unwrap());


  • Helper macro for creating instances of Filling.
  • Helper macro for converting types into Filling::Text. It’s used internally by the filling! and filling_list! macros.



  • Represents a variable in a template hash, can be a string, another template hash or an array of template hash.