Open orsinium opened 4 years ago
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
.
I really don't like this kind of ambiguity. Why not introduce a separate function for that behavior?
Array
Nice!
More tests
Awesome!
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".
GitHub wikis are in a separate git repository: https://github.com/muesli/beehive.wiki.git
I really don't like this kind of ambiguity.
Me too. However, the new behavior (check if any of substrings is in the string) is what I would expect from ContainsAny
. I'd remove the old behavior because ContainsAny "something" "abc"
is the same as ContainsAny "something" "a" "b" "c"
from now on but it would be a breaking change.
Why not introduce a separate function for that behavior?
How would you name it?
I can't come up with anything better than ContainsAnyString
:disappointed: Still open for suggestions :smiley:
A few suggestions:
ContainsAll
. The old implementation of ContainsAny
rename to ContainsAnyRune
.ContainsAny
, extend Contains
instead.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".