TemplateDX combines Markdown and JSX to create powerful, type-safe templates for LLM prompts. This page provides a comprehensive overview of the syntax.Documentation Index
Fetch the complete documentation index at: https://docs.agentmark.co/llms.txt
Use this file to discover all available pages before exploring further.
Basic Structure
Every TemplateDX template is a.mdx file with optional frontmatter and a mix of Markdown and JSX:
Frontmatter
Frontmatter is optional metadata at the top of your file:Variables
Access dynamic data using curly braces:Expressions
Evaluate JavaScript expressions inline:Control Flow
Conditionals
Use<If>, <ElseIf>, and <Else> tags:
Loops
Use<ForEach> to iterate over arrays:
Filters
Transform data with built-in filters. TemplateDX ships 10 filters out of the box:abs, capitalize, dump, join, lower, replace, round, truncate, upper, urlencode.
Components
Create reusable template components:Raw output
Use<Raw> to emit the enclosed content as literal source text — expressions inside <Raw> are not evaluated. The plugin re-serializes its children through Markdown, so you get exactly what you wrote.
{props.variableName} (literal text, not the value of props.variableName).
XML tags
Lowercase XML tags are preserved as-is in the output, making them ideal for prompt engineering patterns like<examples>, <context>, and <instructions>. A fixed allow-list of HTML tags (per supported-tags.ts) also passes through unchanged. Expressions inside these tags are evaluated normally.
Only lowercase tags are treated as XML passthrough. PascalCase tags like
<User>, <System>, and <ForEach> are reserved for TemplateDX built-in tags and components. Variables and expressions inside XML tags are still evaluated normally.Comments
Use JSX-style comments:Fragments
Use fragments to group elements without adding markup:Markdown Support
TemplateDX supports all standard Markdown:Whitespace
TemplateDX preserves whitespace in your templates:Escaping literal braces
To emit literal{ or } in output, wrap the content in <Raw>:
Type safety
See Type safety for the canonical flow —npx agentmark generate-types emits AgentmarkTypes from your prompt schemas. That’s the codegen pipeline AgentMark actually uses at runtime.
TemplateDX itself doesn’t evaluate JSDoc or TypeScript types; comments are stripped at bundle time (bundler.ts:150 removeComments).
Best practices
- Use descriptive variable names —
props.customerNameinstead ofprops.n. - Keep templates modular — break large templates into components.
- Generate types — run
npx agentmark generate-typesand pass the result tocreateAgentMarkClient<AgentmarkTypes>()for compile-time prop validation. - Use conditionals wisely — make prompts adapt to context.
- Leverage filters — transform data at the template level instead of reshaping it in your application code.
Complete Example
Here’s a full example combining multiple features:Next Steps
- Variables - Learn about variable access
- Expressions - JavaScript expressions
- Tags - Control flow and special operations
- Filters - Data transformation
- Components - Reusable templates