Plans & Pricing
About Gavel
Careers
Product Wishlist
Subdomain Log In
Manage Account
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.
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:
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
Sign up for our newsletter to get product updates, exclusive client interviews, and more.