Skip to content

setMacroChars with [ and ] #2412

Open
Open
@sguyomard

Description

@sguyomard

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

I get this result :

image

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 ${ }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions