Liquid include



examples/liquid/liquid-include/templates/page.txt
{% include 'templates/incl/header.txt' %}

title in page template: {{title}}
name in page template: {{name}}

examples/liquid/liquid-include/templates/incl/header.txt
title in header: {{title}}
value in header: {{value}}

examples/liquid/liquid-include/src/main.rs
use liquid::partials::{EagerCompiler, InMemorySource};
use std::fs::read_to_string;

pub type Partials = EagerCompiler<InMemorySource>;

fn main() {
    let mut partials = Partials::empty();
    let filename = "templates/incl/header.txt";
    let template = read_to_string(filename).unwrap();
    partials.add(filename, template);

    let template = liquid::ParserBuilder::with_stdlib()
        .partials(partials)
        .build()
        .unwrap()
        .parse_file("templates/page.txt")
        .unwrap();

    let globals = liquid::object!({
        "title": "Liquid",
        "name": "Foo Bar",
        "value": "some value",
    });
    let output = template.render(&globals).unwrap();
    println!("{}", output);
}

title in header: Liquid
value in header: some value


title in page template: Liquid
name in page template: Foo Bar