3 * @file src/Render/FriendicaSmarty.php
5 namespace Friendica\Render;
8 use Friendica\Core\Renderer;
11 * Friendica extension of the Smarty3 template engine
13 * @author Hypolite Petovan <hypolite@mrpetovan.com>
15 class FriendicaSmarty extends Smarty
17 const SMARTY3_TEMPLATE_FOLDER = 'templates';
21 function __construct()
23 parent::__construct();
26 $theme = $a->getCurrentTheme();
28 // setTemplateDir can be set to an array, which Smarty will parse in order.
29 // The order is thus very important here
30 $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
31 if (!empty($a->theme_info['extends'])) {
32 $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
35 $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
36 $this->setTemplateDir($template_dirs);
38 $this->setCompileDir('view/smarty3/compiled/');
39 $this->setConfigDir('view/smarty3/config/');
40 $this->setCacheDir('view/smarty3/cache/');
42 $this->left_delimiter = Renderer::getTemplateLeftDelimiter('smarty3');
43 $this->right_delimiter = Renderer::getTemplateRightDelimiter('smarty3');
45 $this->escape_html = true;
47 // Don't report errors so verbosely
48 $this->error_reporting = E_ALL & ~E_NOTICE;
51 function parsed($template = '')
54 return $this->fetch('string:' . $template);
56 return $this->fetch('file:' . $this->filename);