Skip to content

Commit

Permalink
Merge pull request #10 from kusmierz/feature/recursive-addChild-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kokspflanze committed May 26, 2017
2 parents fd32967 + eaf04e7 commit 20331c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ZfcTwig/View/TwigRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ public function render($nameOrModel, $values = [])
if (!isset($values['content'])) {
$values['content'] = '';
}
foreach($model as $child) {
foreach ($model as $child) {
/** @var \Zend\View\Model\ViewModel $child */
if ($this->canRender($child->getTemplate())) {
$template = $this->resolver->resolve($child->getTemplate(), $this);
return $template->render((array) $child->getVariables());

$childValues = (array) $child->getVariables();
if ($child->hasChildren()) {
foreach ($child->getChildren() as $grandChild) {
$childValues[$grandChild->captureTo()] = $this->render($grandChild);
}
}

return $template->render($childValues);
}
$child->setOption('has_parent', true);
$values['content'] .= $this->view->render($child);
Expand Down

0 comments on commit 20331c3

Please sign in to comment.