Skip to main content

file

Macro file 

Source
file!() { /* proc-macro */ }
Expand description

Generates a module for a single .hbs file.

The path is relative to the crate root. Partials are resolved against the file’s own directory.

mod button {
    typed_handlebars::file!("doc-templates/button.hbs");
}

assert_eq!(
    button::button::Vars { btn_id: 42, btn_name: "Save" }.render(),
    r#"<button id="btn42">Save</button>"#
);

Reach for directory! unless you want one specific file; it keeps the module layout and the folder layout the same thing.