3 * @file src/Core/Renderer.php
6 namespace Friendica\Core;
9 use Friendica\BaseObject;
10 use Friendica\Core\System;
11 use Friendica\Render\FriendicaSmarty;
14 * @brief This class handles Renderer related functions.
16 class Renderer extends BaseObject
18 private static $ldelim = [
22 private static $rdelim = [
28 * @brief This is our template processor
30 * @param string|FriendicaSmarty $s The string requiring macro substitution or an instance of FriendicaSmarty
31 * @param array $r key value pairs (search => replace)
33 * @return string substituted string
35 public static function replaceMacros($s, $r)
37 $stamp1 = microtime(true);
40 // pass $baseurl to all templates
41 $r['$baseurl'] = System::baseUrl();
42 $t = $a->getTemplateEngine();
45 $output = $t->replaceMacros($s, $r);
46 } catch (Exception $e) {
47 echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
51 $a->saveTimestamp($stamp1, "rendering");
57 * @brief Load a given template $s
59 * @param string $s Template to load.
60 * @param string $root Optional.
62 * @return string template.
64 public static function getMarkupTemplate($s, $root = '')
66 $stamp1 = microtime(true);
68 $t = $a->getTemplateEngine();
71 $template = $t->getTemplateFile($s, $root);
72 } catch (Exception $e) {
73 echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
77 $a->saveTimestamp($stamp1, "file");
83 * Gets the right delimiter for a template engine
89 * @param string $engine The template engine (default is Smarty3)
91 * @return string the right delimiter
93 public static function getTemplateLeftDelimiter($engine = 'smarty3')
95 return self::$ldelim[$engine];
99 * Gets the left delimiter for a template engine
105 * @param string $engine The template engine (default is Smarty3)
107 * @return string the left delimiter
109 public static function getTemplateRightDelimiter($engine = 'smarty3')
111 return self::$rdelim[$engine];