As covered in Register Filters/Tags, we can access filter arguments directly in filter function like:
1 | // Usage: {{ 1 | add: 2, 3 }} |
When it comes to stateful filters, for example transform a URL path to full URL, we’ll need to access a origin in current scope:
1 | // Usage: {{ '/index.html' | fullURL }} |
See this JSFiddle: https://jsfiddle.net/ctj364up/1/
Arrow Functions
thisin arrow functions is bound to current JavaScript context, you’ll need to usefunction(){}instead of()=>{}syntax to accessthis.contextcorrectly.