3 * @file src/Render/FriendicaSmarty.php
5 namespace Friendica\Render;
9 use Friendica\Core\Renderer;
12 * Friendica extension of the Smarty3 template engine
14 * @author Hypolite Petovan <hypolite@mrpetovan.com>
16 class FriendicaSmarty extends Smarty
18 const SMARTY3_TEMPLATE_FOLDER = 'templates';
22 function __construct()
24 parent::__construct();
27 $theme = $a->getCurrentTheme();
29 // setTemplateDir can be set to an array, which Smarty will parse in order.
30 // The order is thus very important here
31 $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
32 if (!empty($a->theme_info['extends'])) {
33 $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
36 $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
37 $this->setTemplateDir($template_dirs);
39 $this->setCompileDir('view/smarty3/compiled/');
40 $this->setConfigDir('view/smarty3/config/');
41 $this->setCacheDir('view/smarty3/cache/');
43 $this->left_delimiter = Renderer::getTemplateLeftDelimiter('smarty3');
44 $this->right_delimiter = Renderer::getTemplateRightDelimiter('smarty3');
46 $this->escape_html = true;
48 // Don't report errors so verbosely
49 $this->error_reporting = E_ALL & ~E_NOTICE;
52 function parsed($template = '')
55 return $this->fetch('string:' . $template);
57 return $this->fetch('file:' . $this->filename);