Skip to content
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

Update cloneBlock and replaceBlock to use XML api instead of string search/replace #541

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Supress cleaning value
Take lot of time and not necessary if you well form your template
  • Loading branch information
chervaliery committed Jun 12, 2015
commit 0ae5ee5f220fe2097c5effb22bc51d5f4c62ffe6
10 changes: 5 additions & 5 deletions src/PhpWord/TemplateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ protected function setValueForPart($documentPartXML, $search, $replace, $limit)
{
$pattern = '|\$\{([^\}]+)\}|U';
preg_match_all($pattern, $documentPartXML, $matches);
foreach ($matches[0] as $value) {
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
$documentPartXML = str_replace($value, $valueCleaned, $documentPartXML);
}
// foreach ($matches[0] as $value) {
// $valueCleaned = preg_replace('/<[^>]+>/', '', $value);
// $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
// $documentPartXML = str_replace($value, $valueCleaned, $documentPartXML);
// }

if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
$search = '${' . $search . '}';
Expand Down