Throw an exception on template helpers called outside rendering context

This commit is contained in:
Giuseppe Criscione 2019-05-25 23:17:17 +02:00
parent 4c8ca2d69f
commit f4ee683fb6

View File

@ -257,6 +257,10 @@ class Template
public function __call($name, $arguments)
{
if (TemplateHelpers::has($name)) {
if (!$this->rendering) {
throw new RuntimeException(__METHOD__ . ' is allowed only in rendering context');
}
$helper = TemplateHelpers::get($name);
return $helper(...$arguments);
}