Skip to content

Commit 6a51165

Browse files
authored
Update for setImageValue() inside clonedBlock with indexed values
Using the setImageValue() with image dimensions inside search pattern like ${IMAGE:10cmx15xm} inside a cloned block with indexed values where resulting in ${IMAGE:10cmx15cm#1}. This change in the RegularExpresion of the indexClonedVariables() is changing it to ${IMAGE#1:10cmx15cm} instead. getVariables() will still return the whole pattern, "IMAGE#1:10cmx15cm", maybe it should also be updated to just return the raw field name "IMAGE#1".
1 parent fe531ca commit 6a51165

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ protected function indexClonedVariables($count, $xmlBlock)
10851085
{
10861086
$results = array();
10871087
for ($i = 1; $i <= $count; $i++) {
1088-
$results[] = preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlBlock);
1088+
$results[] = preg_replace('/\$\{(.*?)(:([^}])*)?\}/', '\${\\1#' . $i . '\\2}', $xmlBlock);
10891089
}
10901090

10911091
return $results;

0 commit comments

Comments
 (0)