dust-php icon indicating copy to clipboard operation
dust-php copied to clipboard

FIlter documentation inaccurate

Open larryweya opened this issue 10 years ago • 0 comments

According to the docs, filters are created as callable functions

$dust->filters['striptags'] = function ($value) {
    //not a string, nothing to do
    if (!is_string($value)) {
        return $value;
    }
    //otherwise strip the tags
    return strip_tags($value);
}

Which results in Call to undefined method Closure::apply()

I had to create a subclass of \Dust\Filter\Filter to get it to work.

class DateFilter implements \Dust\Filter\Filter {
    public function apply($value) {
            return date('d/m/Y', (new DateTime($value))->getTimestamp());
    }
}

larryweya avatar Sep 24 '14 09:09 larryweya