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

Conditional Logic In Microsoft Templates (DOCX, PPTX, XLSX)

Use the correct square-bracket syntax for RENDER blocks and merge fields in DOCX templates.

Use this page when your RENDER statement works in the HTML editor but needs DOCX syntax.

The logic stays the same.

The wrapping syntax changes.

Core rules

  1. Wrap opening and closing RENDER tags in square brackets.

  2. Keep the logical expression inside the RENDER tag.

  3. Wrap merge fields in DOCX content with square brackets.

Basic pattern

docx-render-basic.txt
[<!--RENDER='{{!Opportunity.StageName}}' == 'Closed Won' -->]
  This opportunity is closed won.
[<!--ENDRENDER-->]

Show conditional content with a merge field

Use square brackets for the merge field inside the rendered content.

docx-render-with-merge-field.txt
[<!--RENDER='{{!Contact.Phone}}' != 'NULL' -->]
  Phone number: [{{!Contact.Phone}}]
[<!--ENDRENDER-->]

Use AND and OR

&&, ||, and parentheses work in DOCX too.

Use nested render blocks

Nested render blocks follow the same naming rules as standard templates.

Use the same operators you use in standard conditional logic.

That includes ==, !=, >, <, >=, <=, CONTAINS, NOT CONTAINS, &&, and ||.

Common fixes

  • Blank output: Make sure both the opening tag and the closing tag use square brackets.

  • Field prints as text: Use [{{!FieldName}}] in DOCX content.

  • Nested logic fails: Match RENDER1 with ENDRENDER1, RENDER2 with ENDRENDER2, and so on.

  • Expression is hard to debug: Test the logic in a standard template first. Then convert the outer wrapping for DOCX.

Keep going

Last updated

Was this helpful?