-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setMacroChars with [ and ] #2412
Comments
Same here, this is because, fixBrokenMacros function is called before macro changed by setMacroChar |
fixBrokenMacros is called on TemplateProcessor.php Class Instanciation (and so it's too late to change it after class instanciation) But macroOpeningChars and macroClosingChars are static, so if you define TemplateProcessor::setMacroChars('[', ']'); (it means in TemplateProcessor.php to replace public function setMacroOpeningChars(string $macroOpeningChars): void
by public static function setMacroOpeningChars(string $macroOpeningChars): void
) |
when using setMaroChars with [ and ] as starting and closing char, the template processor doesn't replace maros
the word docx file was made with office365, not online, word installed on a laptop.
Steps to Reproduce
$templateProcessor = new TemplateProcessor($localWordFileName);
$templateProcessor->setMacroChars('[', ']');
in $this->tempDocumentMainPart, I have for example :
<w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t xml:space="preserve">Nous avons bien réceptionné votre demande du </w:t></w:r><w:r w:rsidR="00790EED"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t>{{</w:t></w:r><w:r w:rsidR="10F8EA5E" w:rsidRPr="22CC4AC1"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t>dateSoumis</w:t></w:r><w:r w:rsidR="00790EED"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t>}}</w:t></w:r><w:r w:rsidRPr="22CC4AC1"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t xml:space="preserve"> et vous remercions pour la confiance que vous nous accordez : </w:t></w:r></w:p><w:p w14:paraId="0F17B8AC" w14:textId="77777777" w:rsidR="00380A60" w:rsidRDefault="033A9107" w:rsidP="002C51CC"><w:pPr><w:spacing w:after="38"/><w:ind w:left="567" w:hanging="10"/></w:pPr><w:r w:rsidRPr="22CC4AC1"><w:rPr><w:sz w:val="14"/>
can't find out how str_replace($search, $replace, $documentPartXML) could work in this ?
the same xml part without specific marcoChars :
w:rsidRDefault="033A9107" w:rsidP="002C51CC"><w:pPr><w:spacing w:after="5" w:line="265" w:lineRule="auto"/><w:ind w:left="567" w:hanging="10"/></w:pPr><w:r w:rsidRPr="22CC4AC1"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t xml:space="preserve">Nous avons bien réceptionné votre demande du </w:t></w:r><w:r w:rsidR="00334903"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t>${dateSoumis}</w:t></w:r><w:r w:rsidRPr="22CC4AC1"><w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr><w:t xml:space="preserve"> et vous remercions pour la confiance que vous nous accordez : </w:t></w:r></w:p><w:p w14:paraId="0F17B8AC" w14:textId="77777777" w:rsidR="00380A60" w:rsidRDefault="033A9107" w:rsidP="002C51CC"><w:pPr><w:spacing w:after="
here the macro is clean
if I put a $ and a { , here a piece of templace.docx :
![image](https://private-user-images.githubusercontent.com/118456611/246440245-2f572dad-d717-462c-96b8-663a3c604605.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5MzkzMTYsIm5iZiI6MTcxODkzOTAxNiwicGF0aCI6Ii8xMTg0NTY2MTEvMjQ2NDQwMjQ1LTJmNTcyZGFkLWQ3MTctNDYyYy05NmI4LTY2M2EzYzYwNDYwNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyMVQwMzAzMzZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZWU0ZTE1MzdiMTJhMWU0NmNiZmIwZjFlNGViMjAwMDI1ZDRmMGRmNDgwNDY5ODM4MDMxMThkODczOTUwNzA5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.GApfsIi3tJa6kGnZKg5sitqADglFPdRohP0k3FiUAuk)
I get this result :
it seems there is a glinch in the matrix with ${
Expected Behavior
example : [client_name] replaced by client name
Current Behavior
nothing replaced, we got [client_name]
I tried diffrent patterns like {# and }, [#, #], etc nothing works, only ${ }
The text was updated successfully, but these errors were encountered: