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
+8 -7
View File
@@ -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);
}
/**