@bwilliamson/template-engine-cli
v0.0.4
Published
CLI for the secure templating engine
Readme
@bwilliamson/template-engine-cli
Command-line tool for rendering mergeEngine-style templates with JSON data.
Pre-1.0: Expect breaking changes in CLI flags and template syntax until
1.0.0. Pin exact versions and check release notes before upgrading.
Requires Node.js >= 22.12.
Install
npm install -g @bwilliamson/template-engine-cliUsage
template-engine --template template.txt --data data.json
cat template.txt | template-engine --data data.json
template-engine --helpOptions
| Flag | Required | Description |
| ------------------- | -------- | -------------------------------------------- |
| --data <file> | Yes | JSON file used as the template data context |
| --template <file> | No | Template file; reads from stdin when omitted |
| --help | No | Show usage |
Rendered output is written to stdout. Errors (including parse failures with source location) go to stderr.
Example
data.json
{ "name": "World" }template.txt
Hello, <#name#>!template-engine --template template.txt --data data.json
# Hello, World!Template language
The CLI uses legacy syntax — the same language parsed by parseLegacy in @bwilliamson/template-engine-core.
| Construct | Syntax | Purpose |
| ------------- | ------------------------- | ----------------------------------------- |
| Variable | <#name#> | Insert a value from --data |
| Loop | <~ ... <*> <[items]> ~> | Repeat for each array element |
| Conditional | <~<+> ... <?cond?> ~> | Render one branch |
| Function call | <{fn(...)}> | Not available in the CLI (empty registry) |
See the Template Language Reference for the complete guide.
Behavior notes
Stdin: The CLI reads the entire stdin stream before parsing. It does not wait for more input when a tag looks incomplete; if the stream closes mid-tag, parsing fails with a syntax error.
Functions: The CLI intentionally registers no template functions. For custom functions, use the core library in a host application.
Standalone executable
For environments without Node.js, build a single-file binary from the monorepo root:
pnpm --filter @bwilliamson/template-engine-cli run build:standalone:linux # or :macos / :windowsOutput lands in packages/template-engine-cli/dist/. See DEVELOPERS.md for release details.
