cretz / dust-php

Powerful PHP templating engine based off of Dust JS
http://cretz.github.com/dust-php
MIT License
67 stars 19 forks source link

FIlter documentation inaccurate #8

Open larryweya opened 9 years ago

larryweya commented 9 years ago

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());
    }
}