Browse Source

Twig filter 'matches'

master
parent
commit
6df44a9e20
  1. 3
      doc/TwigJS.md
  2. 3
      src/twigFunctions.js

3
doc/TwigJS.md

@ -22,6 +22,9 @@ There are several extra functions defined for the TwigJS language:
* function `tagsPrefix(tags, prefix)`: return all tags with the specified prefix. The result will be an array with `{ "en": "name:en", "de": "name:de" }` (for the input `{ "name": "foo", "name:en": "english foo", "name:de": "german foo" }` and the prefix "name:").
* function openingHoursState(opening_hours_definition): returns state of object as string: 'closed', 'open' or 'unknown'.
Extra filters:
* filter `matches`: regular expression match. e.g. `{{ "test"|matches("e(st)$") }}` returns `[ "est", "st" ]`. Returns null if it does not match.
Notes:
* Variables will automatically be HTML escaped, if not the filter raw is used, e.g.: {{ tags.name|raw }}
* The templates will be rendered when the object becomes visible and when the zoom level changes.

3
src/twigFunctions.js

@ -29,3 +29,6 @@ OverpassLayer.twig.extendFunction('openingHoursState', function (openingHours) {
return oh.getStateString(new Date(), true)
})
OverpassLayer.twig.extendFilter('matches', function (value, match) {
return value.match(match)
})
Loading…
Cancel
Save