spatial-monorepo / ui/src / renderTemplate
Function: renderTemplate()
renderTemplate(
template,data):string
Defined in: packages/ui/src/InfoCard/renderTemplate.ts:20
Extended Handlebars-style template renderer.
Supports:
- Simple variable substitution: {{key}}
- Inline helpers: {{helperName arg1 arg2}}
- Block helpers: {{#helperName arg1 arg2}}...{{/helperName}}
Inline helpers: {{fallback value "default"}} — value if truthy, else the literal string {{formatDate value "YYYY-MM-DD"}} — format a timestamp (ms); tokens: YYYY MM DD HH mm ss (UTC) {{formatNumber value N}} — value.toFixed(N) {{json value}} — JSON.stringify(value, null, 2)
Block helpers: {{#ifEquals a b}}...{{/ifEquals}} — render content if a === b (string comparison)
Unknown helpers throw Error: Unknown helper: "name"
Parameters
template
string
data
Record`<string, unknown>`
Returns
string
