From 1aec69bb9a9796fdd44d8256561cb76093fc6ee3 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 22 Mar 2010 17:15:09 -0400 Subject: [PATCH] Updated render initialization code. Now passes $this as the view object unless an external view object is provided. --- Mustache.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Mustache.php b/Mustache.php index 1ff5df3..3479ab0 100644 --- a/Mustache.php +++ b/Mustache.php @@ -45,7 +45,7 @@ class Mustache { * * Defaults to the template and view passed to the class constructor unless a new one is provided. * Optionally, pass an associative array of partials as well. - * + * * @access public * @param string $template (default: null) * @param mixed $view (default: null) @@ -54,9 +54,16 @@ class Mustache { */ public function render($template = null, $view = null, $partials = null) { if ($template === null) $template = $this->template; - if ($view === null) $view = $this->view; if ($partials !== null) $this->partials = $partials; + if ($view === null) { + if ($this->view) { + $view = $this->view; + } else { + $view = $this; + } + } + $template = $this->renderSection($template, $view); return $this->renderTags($template, $view); }