<If>, <ElseIf>, <Else>, <ForEach>, <Raw>) and exposes two ways to register your own: a global static API and a per-instance API on TemplateDX.
Creating custom tags (TypeScript)
Extend TagPlugin
Create a class that extends TagPlugin and implements transform:
The transform method
transform(props, children, context) must return a Promise<Node | Node[]>.
context: PluginContext exposes:
tagName has type string, but the conditional plugin (tag-plugins/conditional.ts) defensively guards if (!tagName) throw .... Built-in tags can rely on tagName having a value; advanced consumers that invoke a plugin’s transform directly (outside the transformer) should pass a valid name.nodeHelpers surface
Register the plugin (static or instance API)
The registry exposes both a static API (process-wide) and an instance API (scoped to aTemplateDX engine).
Static (global) registration is the simplest path; everything using the default transform/stringify exports sees it:
new TemplateDX({ includeBuiltins: true }) copies the static built-ins (If, ElseIf, Else, ForEach, Raw) into the instance; pass false to start empty.
Use the tag in a template
Example: Quote tag
stringify step backslash-escapes line-leading > in text nodes (the same mechanism that escapes { and <), so blockquote markers your plugin emits appear escaped in the rendered output.
Creating custom tags (Python)
agentmark-templatedx (Python) mirrors the TS surface. Subclass TagPlugin, implement async def transform, and register via the static (register_global) or instance API.
PluginContext dataclass has node_helpers (snake_case mirror of the TS NodeHelpers surface), create_node_transformer, scope, and tag_name.
For instance-scoped registration, construct the engine and use register_tag_plugin:
Built-in tags
ForEach
The ForEach tag loops over an array.
Syntax
arr: Array<T>: an array of items you want to iterate onchildren: (item: T, index: number) => any: a callback function for each item
Conditionals
TheIf, ElseIf, and Else tags let you conditionally output content.
Syntax
If / ElseIf:
condition: boolean: the condition to checkchildren: Node: the node to render if the condition is true
Else:
children: Node: the content to render if no previous condition matched
Raw
TheRaw tag outputs its children verbatim, without expression interpolation.
Syntax
children: Node: the raw text