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 Environment;
use Value;
Notes
-
The approach is useful to me for making single site pages where I generate everything at build time
-
The approach uses `render_str() [TODO: Code shorthand span ] which is a one shot for the render. If the template will be used multiple times it's more efficient to use `add_template() [TODO: Code shorthand span ] to load it once then use it multiple times p:2noaza1kjtyk
-
The JSON data could be loaded dynamically for a more flexible approach
-
And, of course, the templates could be loaded dynamically as well if they needed to change. That would lead to the code in the other postop