embed_templates!() { /* proc-macro */ }Expand description
Embeds all template files from a directory at compile time.
This macro walks the specified directory, reads all files with recognized
template extensions, and returns an EmbeddedTemplates source that can
be used with RenderSetup or converted to a TemplateRegistry.
§Supported Extensions
Files are recognized by extension (in priority order):
.jinja(highest priority).jinja2.j2.txt(lowest priority)
When multiple files share the same base name with different extensions
(e.g., config.jinja and config.txt), the higher-priority extension wins
for extensionless lookups.
§Hot Reload Behavior
- Release builds: Uses embedded content (zero file I/O)
- Debug builds: Reads from disk if source path exists (hot-reload)
For working examples, see standout/tests/embed_macros.rs.
§Compile-Time Errors
The macro will fail to compile if:
- The directory doesn’t exist
- The directory is not readable
- Any file content is not valid UTF-8