Prevent collision of $template variable.

pull/92/head
Mike Cao 11 years ago
parent 24e069bafe
commit 6239ab4d80

@ -28,6 +28,13 @@ class View {
*/ */
protected $vars = array(); protected $vars = array();
/**
* Template file.
*
* @var string
*/
private $template;
/** /**
* Constructor. * Constructor.
* *
@ -96,10 +103,10 @@ class View {
* @throws \Exception If template not found * @throws \Exception If template not found
*/ */
public function render($file, $data = null) { public function render($file, $data = null) {
$template = $this->getTemplate($file); $this->template = $this->getTemplate($file);
if (!file_exists($template)) { if (!file_exists($this->template)) {
throw new \Exception("Template file not found: $template."); throw new \Exception("Template file not found: {$this->template}.");
} }
if (is_array($data)) { if (is_array($data)) {
@ -108,7 +115,7 @@ class View {
extract($this->vars); extract($this->vars);
include $template; include $this->template;
} }
/** /**

Loading…
Cancel
Save