function render(PartialView $view, array $arguments, $body) { if (count($arguments) !== 3) { throw new \InvalidArgumentException('Exactly three arguments must be specified'); } elseif ($arguments[1] !== 'as') { throw new \InvalidArgumentException('The second argument must be as'); } $partial = new PartialView($view); $partial->setVariable($arguments[2], $view->getVariable($arguments[0])); return $partial->renderPartial($body); }
function render(PartialView $view, array $arguments, $body) { if (count($arguments) !== 3) { throw new \InvalidArgumentException('Exactly three arguments must be specified'); } elseif ($arguments[1] !== 'in') { throw new \InvalidArgumentException('The second argument must be in'); } $rendered = ''; foreach ($view->getVariable($arguments[2]) as $value) { $partial = new PartialView($view); $partial->setVariable($arguments[0], $value); $rendered .= $partial->renderPartial($body); } return $rendered; }