Open dave-kennedy opened 2 years ago
Okay, that's definitely what's happening. I deleted the map
filter from PicoTwigExtension.php and magically got the desired behavior.
It's easy enough to get the Pico behavior using the Twig filter with something like {{ pages | map(p => p.title }}
instead of {{ pages | map('title') }}
. How difficult would it be to remove? Or maybe proxy the Twig filter in a backwards compatible way?
I wonder if the filter is being replaced by Pico's own
map
filter
This is exactly the reason, Twig added this filter after we did. I'll remove it from Pico 3.0, since we're breaking BC anyway and it can be replaced by Twig's map
filter (or the column
filter for simple usages).
Just for the record: Twig 2 also introduced the sort
filter as replacement for Pico's sort_by
filter. Since the latter also supports a fallback and since it doesn't conflict with any of Twig's built-in filters, I'll leave it as-is for now.
This should probably also be noted in https://github.com/picocms/picocms.github.io/pull/54, as well as changed in the docs. 🤔
Just mentioning here that way it gets linked to over there. 😉
According to the Twig documentation, this example should display "Bob Smith, Alice Dupond":
However, it throws the following error:
The second example doesn't throw an error:
However, instead of displaying "Bob Smith, Alice Dupond" it displays "Smith, Dupond".
What I'd really like to do is map a list of tags to lowercase, e.g.:
I've tried several variations, including:
{{ tags | map(t => t | lower) | join(', ') }}
{{ tags | map(t => t | lower()) | join(', ') }}
{{ tags | map(t => t.lower) | join(', ') }}
{{ tags | map(t => t.lower()) | join(', ') }}
{{ tags | map(t => t | lower(t)) | join(', ') }}
{{ tags | map(t => t.strtolower) | join(', ') }}
{{ tags | map(t => t.strtolower()) | join(', ') }}
None of these work -- the output is always "Foo, Bar, Blah" -- yet none throw an error. It seems that anything I pass to the
map
filter it simply ignored. I wonder if the filter is being replaced by Pico's ownmap
filter, which works as described here:Any ideas?