I want to pretty print a number. This number comes from the database as application.students.matrikel.
The number has 7 or 8 digits and it has to be displayed in this way: 12-345-678. If it has only 7 digits, a zero must be prepended (01-234-567).
I added a new filter to Volt:
$compiler = $volt->getCompiler();
// format number
$compiler->addFilter('pretty', function($resolvedArgs, $exprArgs)
{
$padded = sprintf('%08s', $resolvedArgs);
$formatted = substr($padded, 0, 2).':'.substr($padded, 2,3).':'.substr($padded, 5,3);
return $formatted;
});
In the view, I use
{{ application.students.matrikel|pretty }}
but this gives me always a parse error.
What am I missing?