Jinja2 - Table row manipulation issue with if statement

Viewed 82

I'm trying to change my word document tagging from: (sorry I don't have enough reputation to embed images :()

current template format

to something like this (I've used the python-docx jinja helper '{%tr if' but open to using anything!)

future template format

  • The main reason for this is to have clean blocks that I can then copy/paste and move around large tables. In the current template format I need to copy/paste blocks then tweak the remaining if condition parts from the rows above.
  • What I've proposed doesn't work, the parser complains. If I move banana_condition2 to the start of the line below (before Banana) then if banana_condition2 fails I end up with a blank row which I don't want.

Thanks in advance!

0 Answers
Related