Hello,
The easiest approach is to do it in two steps:
1. Open the docx as a template and use the replaceTableVariable to replace the placeholders. Instead of adding the HTML, you should add new placeholders. And save then document.
2. Open the previous save document as a new template and then use the replaceVariablebyHTML method to replace the placeholders added in the first step.
Regards.