Include A Minijinja Template And JSON Data Directly In A Rust Binary

This is what I'm using for the initiail setup of my Bunkers And Badasses Virtual Dice Roller. It embeds a Minijinja template and JSON data directcly into the Rust binary.

use minijinja::Environment;
use serde_json::Value;

fn main() {
    let template = include_str!("template.j2");
    let json = include_str!("data.json");
    let output = render(template, json);
    dbg!(output);
}

fn render(template: &str, json: &str) -> String {
    let data: Value = serde_json::from_str(json).unwrap();
    let env = Environment::new();
    env.render_str(template, data).unwrap()
}

Notes

~ fin ~

References