Skip to content

TemplateProcessor: Added a method to replace multiple XML blocks #2741

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sr-44
Copy link

@sr-44 sr-44 commented Feb 4, 2025

Description

Often you will need to replace variables with a new XML block. Currently, there is already a replaceXmlBlock method that replaces only the first occurrence of a variable. To replace all of them, you will need to call this method again. This makes the code unreadable, and sometimes there is a chance that the number of these variables is determined dynamically (in my case it is). I have added a new public method replaceMultipleXmlBlocks, which uses the new protected method findAllContainingXmlBlockForMacro and solves this problem. I would be glad if my contribution is accepted!

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

@coveralls
Copy link

coveralls commented Feb 4, 2025

Coverage Status

coverage: 96.738% (-0.01%) from 96.749%
when pulling 209321f on sr-44:feature/replace-multiple-xml-blocks
into 1be7a80 on PHPOffice:master.

@sr-44
Copy link
Author

sr-44 commented Feb 6, 2025

@Progi1984 can you please review this PR?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants