Cookbook
Clean existing blocks
javadocx includes several methods to work with block elements. These elements allow to define regions made of one or more contents in a DOCX, which can be cleaned of placeholders, deleted and cloned.
The deleteTemplateBlock method deletes block placeholders along with the whole of the region they enclose. This functionality allows to define optional regions in a DOCX template and decide whether or not to delete them dynamically.
E.g., the code that follows replaces an existing placeholder in a document, then erases the whole region delimited by $BLOCK_CHARTS$ placeholders and finally cleans the rest of the block placeholders:
Note that to call the deleteTemplateBlock method you have to write the placeholder identifier without neither the $BLOCK_ prefix nor the final $ symbol.