donna.memory.templates¶
donna.memory.templates
¶
Slice 15 — file-based Jinja renderer for vault templates.
Design decision (intentionally narrow):
Templates live on disk under prompts/vault/ and are self-contained:
every template emits its own frontmatter as the first output block, using
the standard Obsidian ---\n...\n--- YAML delimiter. Callers never
pass frontmatter in — the template owns it. The renderer round-trips the
rendered text through python-frontmatter (already on the dependency
tree via :mod:donna.integrations.vault) to return (body, dict).
Why not {% set frontmatter = {...} %}? That would require parsing
the template AST post-render to pull the variable back out. The YAML
block is simpler, matches the file format the vault already stores, and
keeps the renderer dumb.
Missing context keys raise :class:jinja2.UndefinedError thanks to
:class:~jinja2.StrictUndefined — templates must declare every variable
they use, which catches silent mis-renders during development.
See slices/slice_15_template_writes_meeting_notes.md §1 and
spec_v3.md §1.3.
VaultTemplateRenderer
¶
File-based Jinja renderer with StrictUndefined and frontmatter split.
Source code in src/donna/memory/templates.py
render
¶
Render template_name and split out its frontmatter block.
Returns (body, frontmatter_dict). If the rendered text has no
frontmatter block the dict is empty and body is the full
rendered text.
Raises:
| Type | Description |
|---|---|
UndefinedError
|
if the template references a missing context key (via StrictUndefined). |
TemplateNotFound
|
if |