We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Extending Volt's filters (custom filters)

There is a way to create custom filters in Volt. But where the code goes exactly? Into the config file (index.php)?

Sample code:

$compiler = $volt->getCompiler();

$compiler->addFilter('isArray', function($resolvedArgs) {
    return 'is_array('.$resolvedArgs.')';
});


98.9k
Accepted
answer

That must be added to the Volt's service registration, for example:

https://github.com/phalcon/forum/blob/master/app/config/services.php#L15