Hello,
What version of phpdocx are you using? phpdocx handles that broken tags automatically for placeholders; old versions of phpdocx may require cleaning the variables before calling cloneBlock (https://www.phpdocx.com/api-documentation/templates/proccess-a-word-docx-template):
$docx->processTemplate();
Latest releases include the same code embedded in the cloneBlock method. Other template methods include it too.
Regards.