Twig partial() function should not throw exception

This allows checking if a partial exists
This commit is contained in:
Samuel Georges 2017-11-19 14:58:47 +11:00
parent f850b5d7ca
commit 0a428423af
2 changed files with 4 additions and 2 deletions

View File

@ -98,11 +98,12 @@ class Extension extends Twig_Extension
* Renders a partial.
* @param string $name Specifies the partial name.
* @param array $parameters A optional list of parameters to pass to the partial.
* @param bool $throwException Throw an exception if the partial is not found.
* @return string Returns the partial contents.
*/
public function partialFunction($name, $parameters = [])
public function partialFunction($name, $parameters = [], $throwException = false)
{
return $this->controller->renderPartial($name, $parameters);
return $this->controller->renderPartial($name, $parameters, $throwException);
}
/**

View File

@ -37,6 +37,7 @@ class PartialNode extends Twig_Node
->write("echo \$this->env->getExtension('Cms\Twig\Extension')->partialFunction(")
->subcompile($this->getNode('nodes')->getNode(0))
->write(", \$context['__cms_partial_params']")
->write(", true")
->write(");\n")
;