Template Expression
Template expressions let you generate text dynamically from runtime data.
Syntax Overview
Use double curly braces to evaluate an expression:
{{ expression }}Expression rules:
- Plain text outside
{{ ... }}is returned as-is. - Function calls are space-separated:
{{ functionName arg1 arg2 }}. - Use double quotes for arguments with spaces:
{{ lowercase "HELLO WORLD" }}. - Nested calls use parentheses:
{{ uppercase (lowercase "MiXeD") }}. - Curly braces inside quoted strings are allowed (e.g. regex quantifiers like
"[0-9]{3}"). - Block helpers use
#//tags with an optional{{else}}section. - If an expression fails, output is rendered as:
{{ERROR: ...}}.
Data Source
Most templates read values from JSON runtime data through jsonPointer.
Example runtime JSON:
{
"project": {
"name": "Nara",
"version": 12,
"active": true,
"tags": ["vision", "flow"]
},
"node": {
"id": "node-07"
}
}Data Function: jsonPointer
jsonPointer fetches a value from JSON (e.g. node output) using a JSON Pointer path.
{{ jsonPointer pointer }}
{{ jsonPointer pointer indent }}Arguments:
pointer(required): JSON Pointer path, for example"/project/name".indent(optional): integer indentation for pretty JSON output when target is object/array.
Behavior:
- String result: returns string value.
- Number result: converted to string.
- Boolean result: returns
trueorfalse. - Null result: returns empty string.
- Object/array result:
- no indent or indent = 0: compact JSON string.
- indent > 0: pretty-printed JSON.
jsonPointer Examples
-
Read a string value:
Template: {{ jsonPointer "/project/name" }} Output: Nara -
Read a numeric value:
Template: {{ jsonPointer "/project/version" }} Output: 12 -
Read a boolean value:
Template: {{ jsonPointer "/project/active" }} Output: true -
Read an array (compact JSON):
Template: {{ jsonPointer "/project/tags" }} Output: ["vision","flow"] -
Read an array (pretty JSON):
Template: {{ jsonPointer "/project/tags" 2 }} Output: [ "vision", "flow" ] -
Chain with other functions:
Template: {{ uppercase (jsonPointer "/project/name") }} Output: NARA -
Invalid path handling:
Template: {{ jsonPointer "/project/unknown" }} Output: {{ERROR: JSON pointer error: ...}}
jsonPointer and Data References (Flow runtime)
In flow execution, string values that match the internal data-reference prefix are resolved automatically:
- Frame reference in
idFrames-> converted to Base64 string. - Vector frame reference in
idVFrames-> first frame converted to Base64. - This resolution is recursive for objects and arrays returned by
jsonPointer.
Practical effect:
- If JSON contains a data-reference token,
jsonPointercan return encoded image content instead of the raw token.
Note
The exact reference prefix is internal (FlowNodeUtils::jsonDataRefKeyPrefix()) and may differ by runtime version.
Block Helpers: #if / #unless
Conditional blocks inspired by Handlebars #if / #unless.
{{#if condition}}
then content
{{else}}
else content
{{/if}}
{{#unless condition}}
content when falsy
{{else}}
content when truthy
{{/unless}}Rules:
conditionis any expression (often a nested call such as(jsonPointer "/project/active")).{{else}}is optional.- Blocks can be nested.
- Unclosed or mismatched blocks render as
{{ERROR: ...}}.
Truthiness
A condition value is falsy when it is one of:
- empty string
"" "false""0""null""[]"
Everything else is truthy (including "{}").
#ifrenders the then-branch when the condition is truthy.#unlessrenders the then-branch when the condition is falsy.
Examples
{{#if (jsonPointer "/project/active")}}
enabled
{{else}}
disabled
{{/if}}Output:
enabled{{#unless (jsonPointer "/project/tags")}}
no tags
{{else}}
has tags
{{/unless}}Output:
has tagsConditional Functions
Excel-style helpers for inline conditionals. Use the same truthiness rules as #if / #unless.
if
{{ if condition valueIfTrue valueIfFalse }}Arguments:
condition(required)valueIfTrue(required)valueIfFalse(required)
{{ if (jsonPointer "/project/active") "ON" "OFF" }}Output:
ONAND
Returns "true" if all arguments are truthy, otherwise "false".
{{ AND arg1 arg2 ... }}OR
Returns "true" if any argument is truthy, otherwise "false".
{{ OR arg1 arg2 ... }}Combined example
{{ if (AND (jsonPointer "/project/active") (jsonPointer "/project/name")) "ready" "wait" }}Output:
readyString Functions
lowercase
Converts the first argument to lowercase.
{{ lowercase "Hello WORLD" }}Output:
hello worlduppercase
Converts the first argument to uppercase.
{{ uppercase "Hello WORLD" }}Output:
HELLO WORLDcapitalize
Uppercases only the first character of the first argument.
{{ capitalize "nara flow" }}Output:
Nara flowPadding Function
stringPad
Pads a string to target length.
{{ stringPad value targetLength padToken direction }}Arguments:
value(required): source string.targetLength(required): non-negative integer.padToken(optional): token used for padding, default is single space.direction(optional):startorend, default isstart.
Examples:
{{ stringPad "7" 3 "0" "start" }}Output:
007{{ stringPad "ID" 6 "-" "end" }}Output:
ID----{{ stringPad "ABC" 8 "xy" "end" }}Output:
ABCxyxyxErrors:
- Missing required args -> error.
- Non-numeric length -> error.
- Negative length -> error.
- Invalid direction (not
startorend) -> error.
Regex Functions
Excel-like helpers modeled on REGEXTEST / REGEXEXTRACT / REGEXREPLACE.
case_sensitivity (optional for all three):
0(default): case-sensitive1: case-insensitive
regexTest
Checks whether any part of text matches pattern. Returns "true" or "false".
{{ regexTest text pattern }}
{{ regexTest text pattern case_sensitivity }}{{ regexTest "ABC-123" "[0-9]" }}Output:
trueregexExtract
Extracts text matching pattern.
{{ regexExtract text pattern }}
{{ regexExtract text pattern return_mode }}
{{ regexExtract text pattern return_mode case_sensitivity }}return_mode:
0(default): first match string, or empty string if none1: all matches as a compact JSON array, e.g.["a","b"]2: capturing groups from the first match as a JSON array (groups 1..n)
{{ regexExtract "Order 123-45" "[0-9]+-[0-9]+" }}Output:
123-45{{ regexExtract "a1 b2 c3" "[0-9]" 1 }}Output:
["1","2","3"]{{ regexExtract "ab-cd" "([a-z]+)-([a-z]+)" 2 }}Output:
["ab","cd"]regexReplace
Replaces matches of pattern in text with replacement.
{{ regexReplace text pattern replacement }}
{{ regexReplace text pattern replacement occurrence }}
{{ regexReplace text pattern replacement occurrence case_sensitivity }}occurrence:
0(default): replace all matchesn > 0: replace only the nth match from the startn < 0: replace only the |n|th match from the end
Replacement supports ECMAScript backreferences such as $1, $2.
{{ regexReplace "555-123-4567" "[0-9]{3}-" "***-" }}Output:
***-***-4567{{ regexReplace "555-123-4567" "[0-9]{3}-" "***-" 1 }}Output:
***-123-4567Date and Context Functions
datetimeNow
Returns current local datetime.
{{ datetimeNow }}
{{ datetimeNow format }}Format aliases (case-insensitive):
| Format | Meaning | Example shape |
|---|---|---|
(none) / ISO | ISO_EXT_DATE_TIME (default) | 2026-05-23T15:04:12 |
ISO_MILLISEC | ISO_EXT_DATE_TIME_MILLISEC | 2026-05-23T15:04:12.381 |
DATE | ISO_EXT_DATE | 2026-05-23 |
TIME | ISO_EXT_TIME | 15:04:12 |
DATETIME | DISPLAY_DATE_TIME | 2026-05-23 15:04:12 |
Notes:
- Unknown format text falls back to
ISO.
Example:
{{ datetimeNow "DATE" }}Output:
2026-05-23toolId
Returns current flow tool ID from runtime context.
{{ toolId }}Example output:
tool-image-segmentationnodeId
Returns current flow node ID from runtime context.
{{ nodeId }}Example output:
node-07Nested Expression Examples
{{ uppercase (jsonPointer "/project/name") }}{{ stringPad (jsonPointer "/project/version") 4 "0" "start" }}{{ capitalize (lowercase "NARA TEMPLATE") }}{{ if (OR "false" (jsonPointer "/project/active")) "yes" "no" }}{{#if (AND (jsonPointer "/project/active") (jsonPointer "/project/name"))}}
ready
{{else}}
wait
{{/if}}{{ regexReplace (jsonPointer "/node/id") "[0-9]+" "XX" }}Troubleshooting
Unknown function: ...- Function name is not registered in current runtime.
jsonPointer function requires at least one argument- Missing pointer path.
JSON pointer error: ...- Invalid path or path does not exist.
stringPad function requires a numeric length argument- Target length is not an integer.
if function requires three arguments- Missing
valueIfTrueorvalueIfFalse.
- Missing
Unclosed #if block/Mismatched block close- Missing or mismatched
{{/if}}/{{/unless}}.
- Missing or mismatched
regexTest pattern error: .../regexExtract pattern error: .../regexReplace pattern error: ...- Invalid regular expression pattern.