function replace_macros($s, $r) { global $t; $stamp1 = microtime(true); $a = get_app(); if ($a->theme['template_engine'] === 'smarty3') { $template = ''; if (gettype($s) === 'string') { $template = $s; $s = new FriendicaSmarty(); } foreach ($r as $key => $value) { if ($key[0] === '$') { $key = substr($key, 1); } $s->assign($key, $value); } $output = $s->parsed($template); } else { $r = $t->replace($s, $r); $output = template_unescape($r); } $a = get_app(); $a->save_timestamp($stamp1, "rendering"); return $output; }
public function replace_macros($s, $r) { $template = ''; if (gettype($s) === 'string') { $template = $s; $s = new FriendicaSmarty(); } foreach ($r as $key => $value) { if ($key[0] === '$') { $key = substr($key, 1); } $s->assign($key, $value); } return $s->parsed($template); }
public function replace_macros($s, $r) { $template = ''; if (gettype($s) === 'string') { $template = $s; $s = new FriendicaSmarty(); } // "middleware": inject variables into templates $arr = array("template" => basename($s->filename), "vars" => $r); call_hooks("template_vars", $arr); $r = $arr['vars']; foreach ($r as $key => $value) { if ($key[0] === '$') { $key = substr($key, 1); } $s->assign($key, $value); } return $s->parsed($template); }