Skip to main content

emit_embedded_registry

Function emit_embedded_registry 

Source
pub fn emit_embedded_registry(input_dir: &Path, output_rs: &Path) -> Result<()>
Expand description

Walk input_dir for *.forge.html and emit a Rust source file that registers each template’s raw source via inventory::submit! as a spark::template::EmbeddedTemplate. The user includes this from their crate root with:

include!(concat!(env!("OUT_DIR"), "/spark_embedded_templates.rs"));

The included inventory::submit! blocks register the embedded sources; spark::template::render then resolves view paths from memory instead of hitting disk, enabling single-binary distribution.

Calling this is optional — apps that don’t include the generated file continue to load templates from resources/views/ at runtime.