Twig partial() function should not throw exception
This allows checking if a partial exists
This commit is contained in:
parent
f850b5d7ca
commit
0a428423af
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue