Conditional Sections in Word Templates
Pattern
Templates use {{IF_TAG}}content{{END_IF_TAG}} to mark conditional content.
Logic
- Check the data field (e.g.,
RELOCATION_PACKAGE) for "Yes"/"No" - If "Yes": strip the
{{IF_RELOCATION}}and{{END_IF_RELOCATION}}markers, keep inner content - If "No": remove the entire block including markers and content
- Handle the case where conditional markers and content may span a single paragraph or multiple paragraphs
Implementation Note
Process conditionals BEFORE placeholder replacement, since the conditional content may itself contain placeholders that should only be replaced if the section is kept.


