From 62435a5705bedd9fefeae6f814cc07d9f4e175ae Mon Sep 17 00:00:00 2001 From: Matt DeClaire Date: Fri, 15 Feb 2013 10:02:30 -0800 Subject: [PATCH] lazily default partialsLoader to loader Conflicts: src/Mustache/Engine.php --- src/Mustache/Engine.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 807dfcc..b892eef 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -113,8 +113,6 @@ class Mustache_Engine if (isset($options['partials_loader'])) { $this->setPartialsLoader($options['partials_loader']); - } else if (isset($options['loader'])) { - $this->setPartialsLoader($options['loader']); } if (isset($options['partials'])) { @@ -228,7 +226,7 @@ class Mustache_Engine public function getPartialsLoader() { if (!isset($this->partialsLoader)) { - $this->partialsLoader = new Mustache_Loader_ArrayLoader; + $this->partialsLoader = $this->loader; } return $this->partialsLoader; @@ -243,12 +241,15 @@ class Mustache_Engine */ public function setPartials(array $partials = array()) { - $loader = $this->getPartialsLoader(); - if (!$loader instanceof Mustache_Loader_MutableLoader) { - throw new Mustache_Exception_RuntimeException('Unable to set partials on an immutable Mustache Loader instance'); + if (isset($this->partialsLoader)) { + if (!$this->partialsLoader instanceof Mustache_Loader_MutableLoader) { + throw new Mustache_Exception_RuntimeException('Unable to set partials on an immutable Mustache Loader instance'); + } + } else { + $this->partialsLoader = new Mustache_Loader_ArrayLoader; } - $loader->setTemplates($partials); + $this->partialsLoader->setTemplates($partials); } /**