In views\Template, do not use base/filter.php wrappers where it's not necessary.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 31 Mar 2014 13:18:30 +0000 (09:18 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 31 Mar 2014 13:18:30 +0000 (09:18 -0400)
views/template.php

index c9ca39ccd27b8a9dcfc28b334792f2d9bcd1f7d6..2aeb4554e53b8cbd4b0e2c34bb65e77f0171cb32 100644 (file)
@@ -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)