Docassemble: Templating Word documents in Docassemble (Part I, Basic Variables and Logic)

How to template Word (.docx) documents in Jinja or Mako in Docassemble.

Documate makes it easy to create Docassemble interviews without using any code. If you're using Word documents on Docassemble, you'll need to format them using Jinja syntax to reference your variables. We've gotten many requests for a cheat sheet on using Jinja in .docx documents loaded to Docassemble or Documate's platform, so we're doing this multi-part series to show you how Docassemble templates variables and logic.

Basic Variables and Conditional Phrases

This article will focus on basic formatting in Docassemble using Jinja and Mako syntax. You can access our other articles for more complex formatting.

1. Insert simple variable names using double curly brackets

In your Word document, surround your variable name with double curly brackets, with a space between the brackets and the variable name, like this:

{{ VariableNameHere }}

Common Errors:

  • Brackets: Make sure you have two brackets on either side of your variable name
  • Spacing: Make sure you have a single space between the brackets before and after your variable name.
  • Variable names should not have spaces in them

2. Logic for Conditional Phrases

You can make the appearance of certain words, sentences, or paragraphs conditional (or dependent) on an answer to an interview question. Here's how to do so with different question types.

The standard syntax for conditions is:

{% if VariableNameHere %}Conditional text here.{% endif %}

Yes/No: If the condition comes from a yes/no question, you will use the syntax above.

Multiple Choice: If the condition comes from a multiple choice question, you will use the syntax below:

{% if VariableNameHere == 'multiplechoiceanswer' %}Conditional text here.{% endif %}

Checkbox: If the condition comes from a checkbox question, you will use the syntax below:

{% if VariableNameHere['checkboxanswer']%}Conditional text here.{% endif %}

Check out our article about conditional logic for paragraphs here.

Documate makes it easy to create Docassemble interviews without using any code.  Documate's Word add-in is also available in the Microsoft app store for Docassemble templating of variables, which eliminates the need to use Jinja syntax on Documate.

If you haven't already, check out the rest of our Docassemble resources:

Resources for Docassemble Developers

Jinja Guide Part I: Simple variables and conditional phrases

Jinja Guide Part II: Conditional paragraphs

Jinja Guide Part III: Performing calculations

Jinja Guide Part IV: Numerical calculations

Jinja Guide Part V: Formatting words

Documate Newsletter

Sign up for our newsletter to get product updates, exclusive client interviews, and more.

Start a free trial, or
chat with our team today:

By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.