api-reference.md
May 26, 2026 ยท View on GitHub
Status
The APIs documented here are the canonical public surface for the current release train.
{% raw %}
@templjs/core
Function References
renderTemplate(template, data, options?)
Renders a template string with structured input data.
- Source: src/packages/core/src/index.ts
- Examples/Tests: src/packages/core/test/index.test.ts
import { renderTemplate } from '@templjs/core';
const result = renderTemplate('Hello {{ user.name }}', {
user: { name: 'Ada' },
});
validateTemplate(template)
Validates template syntax and returns { valid, syntaxDiagnostics }.
-
valid: boolean success flag for the full validation pass -
syntaxDiagnostics: ordered lexical/parse diagnostics for tooling and CLI reporting -
Source: src/packages/core/src/index.ts
-
Examples/Tests: src/packages/core/test/index.test.ts
import { validateTemplate } from '@templjs/core';
const result = validateTemplate('{% if user %}Hello{% endif %}');
if (!result.valid) {
console.log(result.syntaxDiagnostics);
}
tokenize(template) and parse(tokens)
Low-level lexer and parser APIs for tooling and diagnostics.
- Source: src/packages/core/src/lexer/lexer.ts, src/packages/core/src/parser/parser.ts
- Examples/Tests: src/packages/core/test/lexer/lexer.test.ts, src/packages/core/test/parser/parser.test.ts
SchemaValidator
Schema-backed data and query-path validation.
- Source: src/packages/core/src/schema/SchemaValidator.ts
- Examples/Tests: src/packages/core/test/schema/SchemaValidator.test.ts
import { SchemaValidator } from '@templjs/core';
const validator = new SchemaValidator({
type: 'object',
properties: { user: { type: 'object' } },
});
createQueryEngine()
Returns a query engine instance with built-in filter metadata.
-
Function catalog tests: src/packages/core/test/query-engine/query-engine.catalog.test.ts
-
Source: src/packages/core/src/index.ts
-
Examples/Tests: src/packages/core/test/index.test.ts
extractTemplateScopeBindings(template)
Extracts scope-relevant variable bindings for semantic tooling.
- Source: src/packages/core/src/semantic/template-scopes.ts
- Examples/Tests: src/packages/core/test/semantic/template-scopes.test.ts
ADRs
- ADR 010: Diagnostics Terminology and Canonical Schema Sources
- ADR 002: Parser Selection
- ADR 003: VS Code Architecture
- ADR 006: Testing Strategy
- ADR 008: Context Graph
@templjs/cli
Render
templjs render -t template.md.tmpl -i data.json
Important flags:
--watch--input-format <json|yaml|toml|xml>--output-format <text|json|html|markdown>--json,--quiet,--verbose--no-validate-input,--no-validate-output
Validate
templjs validate -t template.md.tmpl [-s schema.json] [-i data.json]
Init
templjs init -f markdown [-o starter.md.tmpl]
Stability Notes
- Current package releases are pre-1.0 and move in a shared monorepo release train.
- Public APIs listed above are the recommended integration surface.
{% endraw %}