Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIlter documentation inaccurate #8

Open
larryweya opened this issue Sep 24, 2014 · 0 comments
Open

FIlter documentation inaccurate #8

larryweya opened this issue Sep 24, 2014 · 0 comments

Comments

@larryweya
Copy link

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());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant