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)