include_template

Macro include_template 

Source
macro_rules! include_template {
    ($file:expr) => { ... };
}
Expand description

Include a Tron template file at compile time and create a template instance.

This macro reads a template file during compilation and embeds its contents as a TronTemplate in the resulting binary. The template is parsed and validated at compile time.

§Examples

use tron::include_template;

// Include template from file
let template = include_template!("templates/function.tron");

// Use the template normally
let mut template = template.clone();
template.set("name", "example").unwrap();
template.set("body", "println!(\"Hello!\");").unwrap();
let result = template.render().unwrap();

§Compile-time Validation

The macro validates template syntax at compile time:

// This would cause a compilation error if the template has invalid syntax
let template = include_template!("templates/invalid.tron");

§Path Resolution

Template paths are resolved relative to the crate root or CARGO_MANIFEST_DIR. You can use absolute paths or paths relative to the current file using include_template!(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/file.tron")).