Skip to content
Astera Technology

Keep supplied placeholder-like text literal

Substitute a template once without reinterpreting inserted text.

Download complete case notes and answer keys ↓

Set the decision and its input

The fictional memo literally contains {{total}}. The template also has its own total field of two. A one-pass substitution yields Note: {{total}}; Total: 2. Running total replacement again inside inserted memo text changes the user’s wording to Note: 2.

Filled local test worksheet
CaseInput JSON
Base test{"memo":"{{total}}","total":2}
Download editable CSV ↓

Run the supplied comparison

The code performs deterministic string interpolation. Supplied text is data; it is not permission for another template pass. There is no model, expression evaluator or provider action in this example.

Faulty and required outputs
PathOutput JSON
Faulty path{"output":"Note: 2; Total: 2"}
Required path{"output":"Note: {{total}}; Total: 2"}
Download editable CSV ↓
Complete local Node24.14.1 programme
import assert from 'node:assert/strict';

const run=function run(i,corrected=true){
    if(typeof i.memo!=='string'||i.total===null)return {held:true};
    const source='Note: {{memo}}; Total: {{total}}';
    const output=corrected?source.replace(/\{\{(memo|total)\}\}/g,(_,key)=>String(i[key])):source.replace('{{memo}}',i.memo).replace(/\{\{total\}\}/g,String(i.total));
    return {output};
  };
const cases=[{"input":{"memo":"{{total}}","total":2},"corrected":false,"expected":{"output":"Note: 2; Total: 2"}},{"input":{"memo":"{{total}}","total":2},"corrected":true,"expected":{"output":"Note: {{total}}; Total: 2"}},{"input":{"memo":"Ada","total":0},"corrected":true,"expected":{"output":"Note: Ada; Total: 0"}},{"input":{"memo":"A","total":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Download runnable example ↓

Choose from the boundary evidence

Ordinary Ada text remains Ada and zero total remains zero. Missing required total is held rather than replaced with a guessed blank or amount.

  1. Identify original template slots
  2. Insert values in one pass
  3. Compare preserved field text

Hold a missing required value; do not run inserted text as another template.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
ordinary memo{"memo":"Ada","total":0}{"output":"Note: Ada; Total: 0"}
required value unknown{"memo":"A","total":null}{"held":true}
Download editable CSV ↓

May the memo’s {{total}} become 2 in the base document?

Show the worked answer

No. It is the supplied memo text. Only the original template’s total field becomes 2; the memo keeps its braces.

Related resources