From 38d8c893ebfb727e6f70ee86a155431e8d9fd571 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 31 Mar 2014 09:18:30 -0400 Subject: [PATCH] In views\Template, do not use base/filter.php wrappers where it's not necessary. --- views/template.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/views/template.php b/views/template.php index c9ca39c..2aeb455 100644 --- a/views/template.php +++ b/views/template.php @@ -256,21 +256,20 @@ class Template if ($formatter_pos === FALSE) return 'echo hoplite\\base\\filter\\String(' . $macro . ')'; + $expression = trim(substr($macro, 0, $formatter_pos)); + // Otherwise, apply the right filter. $formatter = trim(substr($macro, $formatter_pos + 1)); $function = ''; switch (strtolower($formatter)) { - case 'int': $function = 'Int'; break; - case 'float': $function = 'Float'; break; - case 'str': $function = 'String'; break; - case 'raw': $function = 'RawString'; break; + case 'int': return "echo intval($expression)"; + case 'float': return "echo floatval($expression)"; + case 'str': return "echo hoplite\\base\\filter\\String($expression)"; + case 'raw': return "echo $expression"; + case 'json': return "echo json_encode($expression)"; default: throw new TemplateException('Invalid macro formatter "' . $formatter . '"'); } - - // Now get the expression and return a PHP statement. - $expression = trim(substr($macro, 0, $formatter_pos)); - return 'echo hoplite\\base\\filter\\' . $function . '(' . $expression . ')'; } protected function _ProcessBuiltin($macro) -- 2.43.5