For the complete documentation index, see llms.txt. This page is also available as Markdown.

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"
}

Template

Result

{#if_display}

Hello {firstname} !

{/if_display}

Your last name is {lastname} !

➡️

Your last name is Doe!

Example 2: block displayed

Data

Template

Result

{#if_display}

Hello {firstname} !

{/if_display}

Your last name is {lastname} !

➡️

Hello John!

Your last name is Doe!

Example 3: block not displayed based on data itself

Data

Template

Result

{#firstname}

Hello {firstname} !

{/firstname}

Your last name is {lastname} !

➡️

Your last name is 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

Template

Result

{#if_display}

Hello {firstname} !

{/if_display}

{^if_display}

Inverted hello {firstname} !

{/if_display}

Your last name is {lastname} !

➡️

Inverted hello John!

Your last name is Doe!

Last updated