-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a few helpful template filters #336
base: master
Are you sure you want to change the base?
Conversation
I really don't like this kind of ambiguity. Why not introduce a separate function for that behavior?
Nice!
Awesome!
GitHub wikis are in a separate git repository: https://github.com/muesli/beehive.wiki.git |
Me too. However, the new behavior (check if any of substrings is in the string) is what I would expect from
How would you name it? |
I can't come up with anything better than |
A few suggestions:
|
Does it make sense for me to keep the PR open any longer or should I just close it? It's ok to not want to merge some random contributions. I'm long enough in open source to understand :) |
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".