j2c
Version:
22 lines (19 loc) • 582 B
Markdown
## filter plugins
A filter plugin is declared as `{$filter: function setup(next, inline){ /* ... */ }}`
They are quite complex so we'll explain how they work by using examples of increasing complexity.
```JS
var takesRawNumber = [...]
{$fliter: function (next) {
return {
decl: function(prop, value) {
if (
!takesRawNumber.includes(prop)
&& (typeof(value) === 'number' || /^\d+$/.test(value.toString())
) {
value = value + 'px'
}
next.decl(prop, value)
}
}
}}
```