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; }
function render(PartialView $view, array $arguments, $body) { if (count($arguments) !== 1) { throw new \InvalidArgumentException('Exactly one variable name must be specified'); } if (is_string($arguments[0]) and substr($arguments[0], 0, 1) === '!') { $condition = !$view->getVariable(substr($arguments[0], 1)); } else { $condition = $view->getVariable($arguments[0]); } if ($condition) { return $body; } else { return ''; } }