-
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
TemplateProcessor::replaceSubstring() #1152
TemplateProcessor::replaceSubstring() #1152
Conversation
But the your string actually reduces to (made a new testcase for this):
so what you actually may want is a global setting where ensureMacroCompleted() is disabled?
edit: fixed static 2 lines of code for the same functionality... Now you TemplateProcessor::$ensureMacroCompletion = false |
@FBnil Your solution is also possible. But mine allow to replace not only variables. Any text. P.S. fixBrokenMacros() is still bad solution. What it will return on strings like: "25$ plus some info {hint}"? It will lost text formation. |
@SailorMax Not quite, if you disable fixBrokenMacros(), then you can search for any text too because it would be the same as your duplicated code from setValue(). And what I propose is 2 lines of changed code, versus your code that actually removes functionality from setValueForPart(). |
@FBnil
|
@SailorMax ok, I see your point now and it is clever code. Naming-wise, i would call it I can not understand this, but the coverage says it's ok, as do the testcases. using preg_quote instead of the xml escaper... mwah... would need to think about bordercases for this. About rewriting TemplateProcessor: I agree (and it is daunting). By using only xml trees you can immediately start using the "other" part of PHPWord. But as you know, TemplateProcessor has always been a bit isolated from the rest of the code. I was thinking an intermediate stage, about something with tables, where you have a makeTable() and get a table object, you populate it with existing commands like ->addCell() and then |
@FBnil preg_quote() used because I have own REG_EXP_DELIMITER, but escaper add his own. Is the current implementation of setValue() didn't do the same as your setBlock(), but without pre-founded list of variables? |
@SailorMax this should not be a problem anymore, as "broken" variable names are being corrected correctly now. |
Agree. replaceBlock() works the same way. |
While TemplateProcessor set variables via replace substrings, but DOCX can has "broken" variables names (
instead of
${aaaaa}
) lets users have option to just replace very_long_variable_names without ${}