Hello,
It's a very good approach. An alternative solution, that could be faster because you don't need to call replaceTableVariable to add a DeleteDelete string, would be removing the tables that contain placeholders (or empty data) after all replacements have been done. If a table contains placeholders then no data has been added and it could be removed.
We have updated the reply with the deleteTemplateBlock information that was removed by mistake :)
Regards.