Skip to content

Conversation

@saig0
Copy link
Member

@saig0 saig0 commented Aug 15, 2025

Description

Add support for string templates. Align with the Feelers library.

  • Template syntax: \```template```\ (tripple backtick)
  • Inline expressions {{variable or express}}
  • Conditional sections {{#if condition}}here{{/if}}
  • Loops {{#loop listValue}} Item: {{this}} {{/loop}}

Example

Template:

```Hello {{user.name}},

We received your order (ID: `{{order.id}}`) with the following items:
{{#loop order.items}}
    - {{this.quantity}}x {{this.name}}
{{/loop}}

Greetings {{department.name}}```

Context:

{
  "user": {
    "name": "Zee"
  },
  "order": {
    "id": "c-8",
    "items": [
      {
        "name": "Helmet",
        "quantity": 1
      },
      {
        "name": "Flag",
        "quantity": 1
      },
      {
        "name": "Oxygen tank",
        "quantity": 3
      }
    ]
  },
  "department": {
    "name": "Camunda"
  }
}

Result:

Hello Zee,

We received your order (ID: `c-8`) with the following items:
    - 1x Helmet
    - 1x Flag
    - 3x Oxygen tank

Greetings Camunda

Related issues

closes #392

Add support for string templates. Align with the Feelers JS library.
@nikku
Copy link
Member

nikku commented Aug 15, 2025

@saig0 before we merge that, are we clear on the actual whitespace semantics, inside a tripple backtick block? Especially as this is a construct that can be arbitrarily nested, this becomes relevant:

{ 
  body: ```
    HELLO {{ user.name }}! How are you?
    
    Greetings {{ us }}
    ```
}

What is the value of body? Is it


........HELLO Nico! How are you?
........
........Greetings Camunda
........

Or are we "smart enough", and remove the leading whitespace (every line) as well as leading and trailing empty lines:

HELLO Nico! How are you?

Greetings Camunda

@saig0 saig0 marked this pull request as draft August 15, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New built-in function for string interpolation

3 participants