Expand description
Template renderer implementation.
Provides the core rendering engine for context templates with:
- Variable substitution (reuses sanitization from prompt module)
- Iteration support (
{{#each collection}}...{{/each}}) - Output format conversion (Markdown, JSON, XML)
Structsยง
- Render
Context - Context for rendering a template.
- Template
Renderer - Template rendering engine.
- XmlState ๐
- State for XML conversion.
Enumsยง
- Render
Value - A value that can be rendered in a template.
Constantsยง
- MAX_
ITERATION_ ๐DEPTH - Maximum nesting depth for iterations (currently only 1 level supported).
- MAX_
ITERATION_ ๐ITEMS - Maximum number of items in an iteration (prevents denial-of-service).
Staticsยง
- EACH_
PATTERN ๐ - Regex pattern for iteration blocks:
{{#each collection}}...{{/each}} - ITEM_
VAR_ ๐PATTERN - Regex pattern for item variable references:
{{item.field}}where item matches collection singular
Functionsยง
- close_
section_ ๐at_ level - Closes section if at or above the given level.
- close_
section_ ๐if_ needed - Closes the current section if one is open.
- escape_
xml ๐ - Escapes special XML characters.
- flush_
section ๐ - Flushes a section to the sections list.
- get_
item_ ๐prefix - Gets the item prefix for iteration (singular form of collection name).
- process_
xml_ ๐line - Processes a single line for XML conversion.