From dd9642bd9ea21d66f1394d073fd2a75306434cc2 Mon Sep 17 00:00:00 2001 From: Jacek Przygoda Date: Fri, 17 Oct 2014 19:37:34 +0200 Subject: [PATCH] Allow multiple view directories for Smarty --- Smarty.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Smarty.php b/Smarty.php index fcf5101..52ceb85 100644 --- a/Smarty.php +++ b/Smarty.php @@ -73,6 +73,22 @@ class Smarty extends \Slim\View */ private $parserInstance = null; + /** + * Set the base directory that contains view templates + * @param string|array $directory + * @throws \InvalidArgumentException If directory is not a directory + */ + public function setTemplatesDirectory($directory) + { + if (is_array($directory)) { + $this->templatesDirectory = array_map(function($element) { + return rtrim($element, DIRECTORY_SEPARATOR); + }, $directory); + } else { + $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR); + } + } + /** * Render Template *