diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index 54d8d95..2c5ebcf 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -48,18 +48,25 @@ class Flashii { } // Initialise Twig - public function initTwig($templateName = null, $templatesFolder = null) { + private function initTwig($templateName = null) { + // Assign default values set in the configuration if $templateName and $templatesFolder are null - $templateName = is_null($templateName) ? self::getConfig('etc', 'design') : $templateName; - $templatesFolder = is_null($templatesFolder) ? self::getConfig('etc', 'templatesPath') : $templatesFolder; + $templateName = is_null($templateName) ? Configuration::getConfig('template') : $templateName; + + // Set variable for public access + self::$_TPLPUBPATH = 'http'. (isset($_SERVER['HTTPS']) ? 's' : '') .'://'. $_SERVER['SERVER_NAME'] . '/templates/'. $templateName; // Initialise Twig Filesystem Loader - $twigLoader = new \Twig_Loader_Filesystem($templatesFolder . $templateName); + $twigLoader = new \Twig_Loader_Filesystem(ROOT_DIRECTORY .'templates/'. $templateName .'/templates'); // And now actually initialise the templating engine - $this->twig = new \Twig_Environment($twigLoader, array( - // 'cache' => $satoko['cacheFolder'] + $this->_TPL = new \Twig_Environment($twigLoader, array( + // 'cache' => ROOT_DIRECTORY. $satoko['cacheFolder'] )); + + // Load String template loader + $this->_TPL->addExtension(new \Twig_Extension_StringLoader()); + } // Initialise Parsedown