Conditional `{{if <condition>}} … {{elseif <condition> }} … {{else}} … {{end}}

Conditional output.

{{if <expression> }} … {{end}}

{{if <expression> }} … {{else}} … {{end}}

{{if <expression> }} … {{elseif <expression>}} … {{end}}

{{if <expression> }} … {{elseif <expression>}} … {{elseif <expression>}} … {{else}} … {{end}}

Input:

{
  "a": -2,
  "b": 4,
  "c": 37,
  "issue": {
    "category": 6
  }
}

Template:

{
  "numbers": [
    {{if a > 0 }} {{ b }} {{else}} {{ c }} {{end}}
  ],
  {{if issue/category }}
    "categorie": {{ issue/category }},
    {{if issue/category = 6 }}
      "is_private": false
    {{else}}
      "is_private": true
    {{end}}
  {{end}}
}

Output:

{
  "numbers": [
    37
  ],
  "categorie": 6,
  "is_private": false
}

Last updated