Skip to content

FIlter documentation inaccurate #8

@larryweya

Description

@larryweya

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions