lazily default partialsLoader to loader

Conflicts:
	src/Mustache/Engine.php
This commit is contained in:
Matt DeClaire
2013-03-12 15:14:04 -07:00
committed by Justin Hileman
parent 8053ce7093
commit 62435a5705
+7 -6
View File
@@ -113,8 +113,6 @@ class Mustache_Engine
if (isset($options['partials_loader'])) { if (isset($options['partials_loader'])) {
$this->setPartialsLoader($options['partials_loader']); $this->setPartialsLoader($options['partials_loader']);
} else if (isset($options['loader'])) {
$this->setPartialsLoader($options['loader']);
} }
if (isset($options['partials'])) { if (isset($options['partials'])) {
@@ -228,7 +226,7 @@ class Mustache_Engine
public function getPartialsLoader() public function getPartialsLoader()
{ {
if (!isset($this->partialsLoader)) { if (!isset($this->partialsLoader)) {
$this->partialsLoader = new Mustache_Loader_ArrayLoader; $this->partialsLoader = $this->loader;
} }
return $this->partialsLoader; return $this->partialsLoader;
@@ -243,12 +241,15 @@ class Mustache_Engine
*/ */
public function setPartials(array $partials = array()) public function setPartials(array $partials = array())
{ {
$loader = $this->getPartialsLoader(); if (isset($this->partialsLoader)) {
if (!$loader instanceof Mustache_Loader_MutableLoader) { if (!$this->partialsLoader instanceof Mustache_Loader_MutableLoader) {
throw new Mustache_Exception_RuntimeException('Unable to set partials on an immutable Mustache Loader instance'); 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);
} }
/** /**