Skip to main content
Install TemplateDX and render a .mdx template against a props object. The snippets below use the Node API (load + transform + stringify) — if you need to bundle templates into a web app, wire up your bundler’s MDX loader separately.

Install

npm install @agentmark-ai/templatedx

Render a template (Node)

Given my-template.mdx:
my-template.mdx
Hi {props.name}, welcome to TemplateDX.
Run it:
import { load, transform, stringify } from "@agentmark-ai/templatedx";

const ast = await load("./my-template.mdx");
const rendered = await transform(ast, { name: "Jim" });
console.log(stringify(rendered));
Output:
Hi Jim, welcome to TemplateDX.
  • load(path) — parses the .mdx file from disk into an AST.
  • transform(ast, props) — evaluates expressions and tag plugins against props.
  • stringify(ast) — serializes the rendered AST back to a Markdown/text string.

Render a template (bundled / web)

When your .mdx is bundled at build time (Next.js, Vite, etc.) and the default export is an AST, you can skip load:
import { transform, stringify } from "@agentmark-ai/templatedx";
import MyTemplate from "./my-template.mdx"; // requires an MDX bundler/loader

const rendered = await transform(MyTemplate, { name: "Jim" });
console.log(stringify(rendered));
Bundling .mdx into a JS module requires an MDX bundler or loader appropriate to your framework — TemplateDX does not ship one.

Next steps

Syntax

Tags, expressions, components, and XML passthrough

Variables

Props and scope resolution

Custom tags

Write your own <Tag> plugins

Custom filters

Extend expression evaluation with filters