Skip to main content

Module template

Module template 

Source
Expand description

Prompt-template engine for .harn.prompt assets and the render / render_prompt builtins.

§Surface

{{ name }}                                 interpolation
{{ user.name }} / {{ items[0] }}           nested path access
{{ name | upper | default: "anon" }}       filter pipeline
{{ if expr }}..{{ elif expr }}..{{ else }}..{{ end }}
{{ for x in xs }}..{{ else }}..{{ end }}   else = empty-iterable fallback
{{ for k, v in dict }}..{{ end }}
{{ include "partial.harn.prompt" }}
{{ include "partial.harn.prompt" with { x: name } }}
{{# comment — stripped at parse time #}}
{{ raw }}..literal {{braces}}..{{ endraw }}
{{- x -}}                                  whitespace-trim markers

Back-compat: bare {{ident}} resolves silently to the empty fallthrough (writes back the literal text on miss) — preserving the pre-v2 contract. All new constructs raise TemplateError on parse or evaluation failure.

Functions§

validate_template_syntax
Parse-only validation for lint/preflight. Returns a human-readable error message when the template body is syntactically invalid; Ok(()) when the template would parse. Does not resolve {{ include }} targets — those are validated at render time with their own error reporting.