I have a model with the following functions:
public function render()
{
$render = craft()->templates->render('myplugin/templates/mymodeltemplate');
return $render;
}
public function __toString()
{
return $this->render();
}
Calling __toString()
gives me the following error:
Fatal error: Method Craft\MyModel::__toString() must not throw an exception in /projectpath/craft/app/vendor/twig/twig/lib/Twig/Extension/Core.php on line 0
I've found this explanation:
http://php.net/manual/en/migration52.incompatible.php
But I'm not sure how to work around it and accomplish what I'm trying to do...