number_format (php) in volt

Hello! How in the Volt output format a number with a partition of the groups (1000 -> 1 000)?



24.7k
edited Mar '17

Hello!

First, you need to register a filter (see https://docs.phalconphp.com/en/latest/reference/volt.html#id2)

$compiler->addFilter('number_format', 'number_format');

Then you need to call this filter like this:

{{  1000|number_format(0, '.', ' ') }}

NOTE: Use those arguments for number_format that are necessary for your task (see http://php.net/number%5format)

edited Mar '17

Thank you. Where should I register the filter? In service.php or in the controller? While I receive an error Unknown filter "number_format"

Where you define view service.

edited Mar '17

Registered in service.php in protected function initSharedVolt