mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
docs: clarification on how to disable tags/filters, see #324
This commit is contained in:
@@ -37,3 +37,25 @@ engine.registerFilter('add', (initial, arg1, arg2) => initial + arg1 + arg2)
|
||||
```
|
||||
|
||||
See existing filter implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/filters>
|
||||
|
||||
## Unregister Tags/Filters
|
||||
|
||||
In some cases it's desirable to disable some tags/filters (see [#324](https://github.com/harttle/liquidjs/issues/324)), you'll need to register a dummy tag/filter in which an corresponding Error throws.
|
||||
|
||||
```javascript
|
||||
// disable a tag
|
||||
const disabledTag = {
|
||||
parse: function(token) {
|
||||
throw new Error(`tag "${token.name}" disabled`);
|
||||
}
|
||||
}
|
||||
engine.registerTag('include', disabledTag);
|
||||
|
||||
// disable a filter
|
||||
function disabledFilter(name) {
|
||||
return function () {
|
||||
throw new Error(`filter "${name}" disabled`);
|
||||
}
|
||||
}
|
||||
engine.registerFilter('plus', disabledFilter('plus'));
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user