Hello,
Since phpdocx 11, that supports using ${ } to wrap placeholders, when using different symbols at the beginning and the end or a symbol greater than 1 byte character, a custom CreateDocxFromTemplate::$regExprVariableSymbols must be set.
In previous versions a single symbol could be used: $, #, @... Using symbols with more than one character was not recommended because MS Word may break them in several tags.
On the API page (https://www.phpdocx.com/api-documentation/templates/set-Word-template-placeholder-variable-symbol) you can read more information about this.
The easiest approach is using a single symbol ($, |, @...) or the default ${ } to wrap placeholders; in these cases you don't need to do any change in CreateDocxFromTemplate::$regExprVariableSymbols.
In your case, as you are using ## to wrap placeholders, please test the following code:
$docx = new CreateDocxFromTemplate('document.docx');
CreateDocxFromTemplate::$regExprVariableSymbols = '##(.*)##';
$docx->setTemplateSymbol('##');
$docx->replaceVariableByText([$key => $placeholderValue]);
A more complex approach could also be used to fix broken ## symbols as MS Word may add:
$docx = new CreateDocxFromTemplate('document.docx');
CreateDocxFromTemplate::$regExprVariableSymbols = '#(.*)#(.*)#(.*)#';
$docx->setTemplateSymbol('##');
$docx->replaceVariableByText([$key => $placeholderValue]);
If you sent to contact[at]phpdocx your sample DOCX we'll check it and test with the parseMode option.
On https://www.phpdocx.com/faqs/forum/default/topic/2172 you can read a post of another user with a similar request.
Regards.