Mergefield does not work with if statement
chlab opened this issue · comments
Christof Leuenberger commented
Expected Behavior
I am trying to use a merge field in an if condition. Ideally, the condition would be evaluated during the mail merge(?). This would make mailmerge templates much more flexible.
My intended use-case is to check a checkbox depending on a placeholder value.
Note: if there is another way to do this (check a checkbox) please let me know!
Current Behavior
The if expression is not evaluated.
Steps to Reproduce
Add a merge field and wrap it in an if condition:
{ IF { MERGEFIELD toggle_test } = "True" "Yes" "No" }
Merge the template as follows:
from mailmerge import MailMerge
with MailMerge('merge_template.docx') as document:
document.merge(
toggle='True'
)
document.write('merge_output.docx')
Your Environment
- Python version: 3.4.2
- docx-mailmerge version: 0.4.0
- Word for Mac Version 16
Ryan Chan commented
Unsure if I am correct or not.
It seems "toggle='True'" should be written as "toggle_test='True'".