-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Milestone
Description
Describe the bug and add attachments
I tried to change the macro chars to the following:
Opening: {{
Closing: }}
The syntax is acording to twig because i want to use the same variables. It is easier for our key users to understand templates.
I found this solution: #2412 (comment)
This doesn't work. So i tried to change the macro chars directly in the via compower downloaded source code. Nothing happens. The template processor can't handle {{ VAR }} - if i change this to any other combination it works.
Expected behavior
The Chars can be changed to {{ }}
Steps to reproduce
No code example required because i tried this also with changing the default variables in the TemplateProcessor.php.
PHPWord version(s) where the bug happened
1.2.0
PHP version(s) where the bug happened
8.0
Priority
- I want to crowdfund the bug fix (with @algora-io) and fund a community developer.I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
Select code repository
Activity
xJuvi commentedon Jul 22, 2025
Hey there,
i tried the last days to find the issue here.
The issue happen as result of the method
fixBrokenMacros
in the TemplateProcessor. The current regex pattern are too static. They're check if the macro is opened by two chars and closed by one char.PHPWord/src/PhpWord/TemplateProcessor.php
Lines 1066 to 1079 in 0ab0b49
It's not easy to solve the pattern. I tried many things. In my test envirenment is found a solution, but now, some of the existing UnitTests doesn't work anymore. With my solution you can use many different chars in combination.
Maybe the UnitTests are incomplete or wrong? I can't repdocue the behavior from the methods
testFixBrokenMacrosWithCustomMacro
andtestFixBrokenMacros
in my test environment...The other thing is the method
ensureMacroCompleted
- there are also the number of chars hardcoded. This is easy to solve.PHPWord/src/PhpWord/TemplateProcessor.php
Lines 259 to 266 in 0ab0b49
This issue is also releated to #2412 and maybe many others.
How will we proceed, @Progi1984 ?
Kind regards
Hannes