Template Rendering CLI
Radiator provides a CLI subcommand for rendering configuration templates outside of Radiator UI. This enables automated configuration generation in deployment pipelines, scripted provisioning, or batch processing scenarios.
Usage
radiator template render [--no-header] <TEMPLATE_FILE> <VALUES_FILE> [OUTPUT_FILE]
radiator template verify <TEMPLATE_FILE> [GENERATED_FILE]
| Argument | Description |
|---|---|
TEMPLATE_FILE | Path to the template file (.radtmpl) |
VALUES_FILE | Path to a JSON file containing template values |
OUTPUT_FILE | Path where the rendered output is written (optional) |
GENERATED_FILE | Path to a rendered configuration file to verify (optional) |
--no-header | Omit the generated-template metadata header from render output |
When OUTPUT_FILE is omitted, the rendered output is written to stdout.
By default, the command prepends the same generated-template metadata header that Radiator UI adds when it creates a configuration from a template. The header records the source template filename, the template checksum, and the values used for rendering. Radiator UI uses this metadata to recognize generated configuration files and reopen them through the template form.
Use --no-header when a script needs only the rendered template body.
Use radiator template verify to validate template files before rendering them. When only TEMPLATE_FILE is provided, the command verifies that the template has valid metadata and valid Handlebars syntax.
When GENERATED_FILE is also provided, the command verifies that the generated file starts with generated-template metadata, that the recorded template checksum matches the current template content, and that the generated file still matches the rendering result for the values stored in its metadata.
Template File Format
Template files use the .radtmpl extension and contain two sections separated by marker lines:
- Metadata section: JSON object defining template fields and their types
- Template body: Handlebars-style template content
# radiator-config-template
{
"description": "Example backend configuration",
"items": [
{
"id": "BACKEND_NAME",
"label": "Backend name",
"type": "string"
},
{
"id": "SECRET",
"label": "Shared secret",
"type": "string"
},
{
"id": "ENABLE_DEBUG",
"label": "Enable debug logging",
"type": "boolean"
}
]
}
# radiator-config-template
backends {
file "{{{BACKEND_NAME}}}" {
secret "{{{SECRET}}}";
{{#if ENABLE_DEBUG}}
debug true;
{{/if}}
}
}
Values File Format
The values file is a JSON object where keys match the id fields defined in the template metadata:
{
"BACKEND_NAME": "my_backend",
"SECRET": "supersecret123",
"ENABLE_DEBUG": true
}
Template Syntax
The template body uses Handlebars syntax for variable substitution and control flow.
Variable Substitution
Use triple braces {{{variable}}} to insert values without HTML escaping (recommended for configuration files):
secret "{{{SECRET}}}";
Double braces {{variable}} apply HTML escaping, which is typically not needed for configuration files.
Missing Variables
Missing variables render as empty strings, allowing partial value sets during development or preview.
Example
Given the template file backend.radtmpl:
# radiator-config-template
{
"description": "File backend configuration",
"items": [
{"id": "NAME", "label": "Backend name", "type": "string"},
{"id": "SECRET", "label": "Secret", "type": "string"},
{"id": "DEBUG", "label": "Debug mode", "type": "boolean"}
]
}
# radiator-config-template
backends {
file "{{{NAME}}}" {
secret "{{{SECRET}}}";
{{#if DEBUG}}
debug true;
{{/if}}
}
}
And values file values.json:
{
"NAME": "production_backend",
"SECRET": "prod_secret_456",
"DEBUG": false
}
Running:
radiator template render backend.radtmpl values.json output.radconf
Produces output.radconf with a generated-template metadata header followed by the rendered body:
# radiator-interpolated-config-template { ... }
# NOTE: This file has been automatically generated from a template file at backend.radtmpl.
#
# The file was generated with the following template values:
# - Backend name: production_backend
# - Secret: prod_secret_456
# - Debug mode: false
#
# Any manual changes to the below configuration will be lost if the template values are
# edited via Radiator UI. You can disable Radiator UI template form for
# this configuration file by removing the radiator-interpolated-config-template comment
# on the first line.
backends {
file "production_backend" {
secret "prod_secret_456";
}
}
To produce the previous body-only output, run:
radiator template render --no-header backend.radtmpl values.json output.radconf
This produces:
backends {
file "production_backend" {
secret "prod_secret_456";
}
}
To output to stdout instead:
radiator template render backend.radtmpl values.json
Stdout output also includes the generated-template metadata header by default. Use --no-header with stdout when you need only the rendered body.
If you want Radiator UI to reopen the generated file through the template form, pass TEMPLATE_FILE as the same relative template path that Radiator UI uses. For example, from the configured template directory, use backend.radtmpl or subdir/backend.radtmpl rather than an unrelated absolute path.
To verify a template before rendering it, run:
radiator template verify backend.radtmpl
To verify that a generated configuration still matches its source template and metadata, run:
radiator template verify backend.radtmpl output.radconf
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (missing file, invalid JSON, template error) |
Error Handling
The command fails with an error message when:
- The template file does not exist or cannot be read
- The values file does not exist or contains invalid JSON
- The output file cannot be written (when specified)
- The template contains syntax errors
- The template metadata is missing or invalid
- The generated file does not contain generated-template metadata on the first line
- The generated file checksum does not match the current template content
- The generated file content no longer matches the rendering result