dust-php
dust-php copied to clipboard
FIlter documentation inaccurate
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());
}
}