docMaker User guide
  • 👋Welcome to docMaker
  • Features
    • Create pdf from docx template
      • 🏗️Build your docx template
        • Overview
        • Text substitution
        • Images
        • Conditions
        • Loops
          • Simple list
          • List with multiple values
          • Adding rows into a table
          • Loops in columns + lines (grids)
          • Nested loops
        • QR codes
        • Rich text & html
      • ⚙️docx_fill_convert API parameters
    • Fill-out pdf forms
      • 🔧Build your pdf form
      • ⚙️pdf_fill API parameters
    • Print web page to pdf
      • ⚙️page_pdf API parameters
  • INTEGRATIONS
    • Typeform
      • Create pdf or docx for each Typeform response
    • Bubble.io
      • 📝Easy pdf from docx template
      • 📋Fill-out pdf forms
      • 🖥️Webpage to pdf
    • Make.com
    • Coda
    • Xano
    • Zapier
    • API
  • FAQ
    • 🫧Bubble.io questions
    • 📄Questions on docx templates
    • 📙Questions on pdf templates
Powered by GitBook
On this page
  • Example 1: block not displayed
  • Example 2: block displayed
  • Example 3: block not displayed based on data itself
  • Example 4: inverted conditions
  1. Features
  2. Create pdf from docx template
  3. Build your docx template

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

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

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

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

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

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

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!

PreviousImagesNextLoops

Last updated 1 year ago

🏗️
➡️
➡️
➡️
➡️