How to use Resultset filter in volt

I need user function filter in Resultset of model But i don't know how to write callback function in volt.

Please help me. Thank.


Volt does not support anonymous functions, but you can still use PHP there:

$filtered = $robots->filter(function($robot){
    if ($robot->id < 3) {
        return $robot;

{% for robot in filtered %}{{ }}{% endfor %}

inb4: I would be great that Volt supports anonymous functions

edited Jul '14


Thank for help but I can't use this way in my case

In controller i use Paginator


use Phalcon\Paginator\Adapter\Model as Paginator;

$paginator = new Paginator(array(
        "data" => $cats,
        "limit" => $limit,
        "page" => $numberPage


And use in views:

{% for index,cat in page.items %} {{ cat.posts.filter({'status=published'}) | length }} {% endfor %}

Thank for help.