Clone and install dependencies:
corepack enable
corepack prepare pnpm@8.15.0 --activate
pnpm install
pnpm build
Create a template file hello.md.templ:
# Hello {{ user.name }}
Items:
{% for item in items %}
- {{ item }}
{% endfor %}
Create a data file data.json:
{
"user": { "name": "Ada" },
"items": ["One", "Two", "Three"]
}
Render from CLI:
From monorepo root (development):
node src/packages/cli/dist/cli.js render -t hello.md.templ -i data.json
After publishing (end users):
npx @templjs/cli render -t hello.md.templ -i data.json
import { renderTemplate } from '@templjs/core';
const output = renderTemplate('Hello {{ user.name }}', {
user: { name: 'Ada' },
});
console.log(output);
Design context (ADRs):
Implementation references:
renderTemplate: src/packages/core/src/index.tstempljs render wiring): src/packages/cli/src/cli.tsrenderCommand: src/packages/cli/src/commands/render.tsvalidateCommand: src/packages/cli/src/commands/validate.tsinitCommand: src/packages/cli/src/commands/init.ts.md.templ, .md.tmpl, .md.tpl.json.templ, .json.tmpl, .json.tpl.yaml.templ, .yaml.tmpl, .yaml.tpl.html.templ, .html.tmpl, .html.tplOptionally configure schema-aware authoring:
{
"templjs.schemaPath": ".templjs/frontmatter.schema.json",
"templjs.contentSchemaPath": ".templjs/content.schema.json",
"templjs.schemas": {
"backlog/**": {
"schemaPath": ".templjs/work-item.frontmatter.schema.json",
"contentSchemaPath": ".templjs/work-item.content.schema.json"
}
}
}