Permalink
Browse files

Prevent calling of render() method from inside templates.

  • Loading branch information...
1 parent 2a7ed5b commit 814f7005134187d769bd9df74a40d345d675cd04 @reinink reinink committed Apr 2, 2014
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/Template.php
View
@@ -120,8 +120,14 @@ public function end()
*/
public function render($name, Array $data = null)
{
+ if (isset($this->_internal['rendering']) and $this->_internal['rendering']) {
+ throw new \LogicException('You cannot render a template from within a template.');
+ }
+
ob_start();
+ $this->_internal['rendering'] = true;
+
$this->data($data);
include($this->_internal['engine']->resolvePath($name));
@@ -137,6 +143,8 @@ public function render($name, Array $data = null)
include($this->_internal['layout_path']);
}
+ $this->_internal['rendering'] = false;
+
return ob_get_clean();
}
}

0 comments on commit 814f700

Please sign in to comment.