Each subdirectory is a self-contained Pony program demonstrating a different part of the templates library. Ordered from simplest to most involved.
Parses a template with a single placeholder, binds a value, and renders the result. Demonstrates the core workflow: Template.parse(), TemplateValues, and Template.render(). Start here if you're new to the library.
Uses {{raw}}...{{end}} syntax to emit literal text without interpreting {{ }} sequences inside it. Useful when the template output itself contains delimiter syntax — for example, generating Mustache templates or documentation about this library. Shows basic raw output and raw blocks combined with trim markers.
Uses {{! ... }} syntax to add comments to templates. Comments are stripped from the output entirely, so they're useful for documenting template logic without affecting rendered text. Shows basic comments and comments combined with trim markers inside loops.
Uses the filter/pipe system to transform values. Demonstrates built-in filters (upper, trim, capitalize, title, default), chaining multiple filters ({{ greeting | trim | capitalize }}), string literals as pipe sources ({{ "hello world" | upper }}), custom filter registration via TemplateContext, and filters inside loops.
Shows how to use if/else, if/elseif/else, and ifnot blocks to conditionally include content based on whether values are present or absent. Demonstrates simple two-branch conditionals, chained multi-branch selection, negated conditionals, and sequence truthiness (guarding a loop with if so it only renders when items are present).
Registers named partials via TemplateContext and inlines them with {{ include "name" }}. Demonstrates reusing template fragments across templates, with partials sharing the same variable scope.
Defines a base HTML layout with {{ block head }} and {{ block content }} sections, then creates a child template that extends the base and overrides both blocks. Demonstrates template inheritance via {{ extends "base" }} and {{ block name }}...{{ end }}.
Uses {{- and -}} trim markers to strip whitespace around tags. Shows how selective trimming produces clean, indentation-sensitive output (like YAML service lists) without unwanted blank lines from control flow tags.
Uses HtmlTemplate for automatic context-aware HTML escaping. Shows how variable output is escaped differently depending on HTML position (text content, URL attributes, etc.) and how to bypass escaping for trusted content with TemplateValue.unescaped and TemplateValues.unescaped.
Demonstrates render_split() and render_to() — the split rendering API that separates template output into static literal segments and dynamic value segments. Shows render_split() returning separate arrays, render_to() driving a custom TemplateSink with alternating literal/dynamic_value calls, and HtmlTemplate.render_split() providing already-escaped dynamic values.