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
ContainsAnyfilter to be able to check if the given string contains any of the given substrings.For example, this one:
{{test or (Contains .title "dephell") (Contains .title "flakehell") (Contains .title "orsinium.dev")}}Can now be transformed into much simpler and shorter expression:
{{test ContainsAny .title "dephell" "flakehell" "orsinium.dev"}}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
ContainsAnylooking 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
Splitbut it's not nice looking. So, let's make one.{{Array "flakehell" "dephell"}}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".