Skip to main content

Module template_renderer

Module template_renderer 

Source
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ยง

RenderContext
Context for rendering a template.
TemplateRenderer
Template rendering engine.
XmlState ๐Ÿ”’
State for XML conversion.

Enumsยง

RenderValue
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.