Conditions

Conditions enable you to control the display of parts of your template based on conditional data:

  • either a boolean (true/ false)

  • or the presence of the data itself

We recommend that when using conditions, you should always use tags starting with if_, like {#if_myTag} text to be dislayed if true {/if_myTag}. This will enable docMaker to know that you are using this tag as a conditional tag.

A condition section begins with a pound and ends with a slash. That is {#if_person} begins a "if_person" section while {/if_person} ends it.

Example : if you use in your template : {#if_myTag} conditional data {/if_myTag} => if you send {"if_myTag" = true} the data inside the{#if_myTag} section will be displayed.

You may also use inverted sections to display data when the condition is false :

Example : in your template : {^if_myTag} conditional data {/if_myTag} => if you send {"if_myTag" = false} the data inside the {^if_myTag} section will be displayed.

Check out the examples below.

Example 1: block not displayed

Data

{
  "if_display" : false,
  "firstname": "John",
  "lastname": "Doe"
}

Example 2: block displayed

Data

{
  "if_display" : true,
  "firstname": "John",
  "lastname": "Doe"
}

Example 3: block not displayed based on data itself

Data

{
  "firstname": null,
  "lastname": "Doe"
}

Example 4: inverted conditions

An inverted section begins with a caret (hat) and ends with a slash. That is {^person} begins a "person" inverted section while {/person} ends it.

Data

{
  "if_display" : false,
  "firstname": "John",
  "lastname": "Doe"
}

Last updated