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

Functions§

embedded_template_names
Every template baked into the framework binary, by canonical name (e.g. "admin/list.html"). Order is stable across builds so a CLI verb that lists them produces deterministic output. Used by rustio override to enumerate copy candidates; project code can also iterate this to build documentation pages.
embedded_template_source
Return the byte-for-byte source of an embedded template by name, or None when no such template exists. Used by rustio override to materialise a copy at <RUSTIO_TEMPLATE_DIR>/<name> so the operator can start editing without first having to find the framework source.