From c8e975a0151c74ea731dc709640310222d884297 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 2 Oct 2023 18:01:05 +0200 Subject: Update Mustache to 46286a1 --- Mustache/Loader/CascadingLoader.php | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Mustache/Loader/CascadingLoader.php (limited to 'Mustache/Loader/CascadingLoader.php') diff --git a/Mustache/Loader/CascadingLoader.php b/Mustache/Loader/CascadingLoader.php new file mode 100644 index 00000000..3fb6353c --- /dev/null +++ b/Mustache/Loader/CascadingLoader.php @@ -0,0 +1,69 @@ +loaders = array(); + foreach ($loaders as $loader) { + $this->addLoader($loader); + } + } + + /** + * Add a Loader instance. + * + * @param Mustache_Loader $loader + */ + public function addLoader(Mustache_Loader $loader) + { + $this->loaders[] = $loader; + } + + /** + * Load a Template by name. + * + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found + * + * @param string $name + * + * @return string Mustache Template source + */ + public function load($name) + { + foreach ($this->loaders as $loader) { + try { + return $loader->load($name); + } catch (Mustache_Exception_UnknownTemplateException $e) { + // do nothing, check the next loader. + } + } + + throw new Mustache_Exception_UnknownTemplateException($name); + } +} -- cgit v1.2.3-55-g7522