Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 832 Bytes

if.md

File metadata and controls

55 lines (45 loc) · 832 Bytes

Conditional ``{{if }} … {{elseif }} … {{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
}