3 * @file src/Core/Renderer.php
6 namespace Friendica\Core;
8 use Friendica\BaseObject;
9 use Friendica\Core\System;
10 use Friendica\Render\FriendicaSmarty;
13 * @brief This class handles Renderer related functions.
15 class Renderer extends BaseObject
18 * @brief This is our template processor
20 * @param string|FriendicaSmarty $s The string requiring macro substitution or an instance of FriendicaSmarty
21 * @param array $r key value pairs (search => replace)
23 * @return string substituted string
25 public static function replaceMacros($s, $r)
27 $stamp1 = microtime(true);
30 // pass $baseurl to all templates
31 $r['$baseurl'] = System::baseUrl();
32 $t = $a->getTemplateEngine();
35 $output = $t->replaceMacros($s, $r);
36 } catch (Exception $e) {
37 echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
41 $a->saveTimestamp($stamp1, "rendering");
47 * @brief Load a given template $s
49 * @param string $s Template to load.
50 * @param string $root Optional.
52 * @return string template.
54 public static function getMarkupTemplate($s, $root = '')
56 $stamp1 = microtime(true);
58 $t = $a->getTemplateEngine();
61 $template = $t->getTemplateFile($s, $root);
62 } catch (Exception $e) {
63 echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
67 $a->saveTimestamp($stamp1, "file");