Skip to main content

Module templates

Module templates 

Source
Expand description

Template rendering. Rust code passes typed context; this module owns everything about HTML generation.

§Loader contract

Per-request lookup via minijinja::Environment::set_loader. On every render call the cache is cleared, forcing the loader closure to re-resolve from disk so a developer can edit a template under RUSTIO_TEMPLATE_DIR and see the change on the next request without restarting the process.

Lookup order, by template name <path>:

  1. <RUSTIO_TEMPLATE_DIR>/<path> — project disk override.
  2. Embedded default — compiled into the binary via include_str!.

Per-model lookup hook: callers that pass a model context can use Templates::render_for_model to add a third tier:

  1. <RUSTIO_TEMPLATE_DIR>/admin/<model>/<page>.html
  2. <RUSTIO_TEMPLATE_DIR>/<path>
  3. Embedded default

Structs§

Templates