Add a few helpful template filters #336
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ContainsAny
I patched
ContainsAny
filter to be able to check if the given string contains any of the given substrings.For example, this one:
Can now be transformed into much simpler and shorter expression:
If only 2 strings are passed into the filter, it behaves as it used to, checking every symbol from the second string to be represented in the first one. While I cannot imagine a use case for it in beehive, let's keep the backward compatibility. It should be ok because
ContainsAny
looking only for one substring would be the same as justContains
.ContainsAll
If we have
ContainsAny
, why not to haveContainsAll
? I've added a new filter to check if a string contains all substrings.Array
There is no syntax in the template engine to create an array but some functions accept arrays. It can be emulated with
Split
but it's not nice looking. So, let's make one.More tests
I've added more tests for string functions. Since there is no way to edit the wiki from the master branch (where is it, BTW?), let's at least have the code "self-documented".