Expand description
Rust macro to parse a JSON file at compile time and compile it into the
program as a serde_json::Value
.
Example — supplying a JSON file as context inside a MiniJinja template:
use include_json::include_json;
fn main() {
let pkg = include_json!(concat!(env!("CARGO_MANIFEST_DIR"), "/package.json"));
let mut env = minijinja::Environment::new();
env.add_template("example", include_str!("example.jinja")).unwrap();
let tmpl = env.get_template("example").unwrap();
println!("{}", tmpl.render(minijinja::context!(pkg)).unwrap());
}