diff --git a/src/ZfcTwig/View/TwigRenderer.php b/src/ZfcTwig/View/TwigRenderer.php index 69ec273..aba7b42 100644 --- a/src/ZfcTwig/View/TwigRenderer.php +++ b/src/ZfcTwig/View/TwigRenderer.php @@ -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);