tera icon indicating copy to clipboard operation
tera copied to clipboard

Allow sort filter to be case insensitive

Open doamatto opened this issue 8 months ago • 10 comments

I saw it was proper ages ago that someone tried bringing case sensitivity to the sort filter and figured I'd go at it. If I'm not mistaken, Tera will use case sensitivity by default (that is, prior to and after this PR) so I only added a test for case insensitivity.

Closes #587 Closes #831 See also : #693

doamatto avatar Apr 19 '25 04:04 doamatto

Thank you so much for writing this patch—I've been looking for this functionality for ages but haven't had the time to implement something myself!

Hope this gets merged soon.

cyckl avatar Apr 19 '25 04:04 cyckl

Wanted to throw in a wee screenshot too of it behaving as expected, as well :

image

Before

image

doamatto avatar Apr 19 '25 04:04 doamatto

@keats Just wanted to follow up to see what your ideas for resolving the MSRV test failing so that we can get this merged and brought upstream to Zola ^_^

doamatto avatar May 03 '25 17:05 doamatto

I think it's fine to merge as is and change the MSRV after merge. By the way I haven't implemented the sort filter yet in tera2 (https://github.com/Keats/tera2) if someone is interesting in porting it.

Keats avatar May 04 '25 19:05 Keats

By the way I haven't implemented the sort filter yet in tera2 (https://github.com/Keats/tera2) if someone is interesting in porting it.

I might have some time to work on it this month — are there any quirks or other things I might need to know about with the new version ?

doamatto avatar May 05 '25 03:05 doamatto

It should be easier to implement, they look more like regular functions. For example: https://github.com/Keats/tera2/blob/master/tera/src/filters.rs#L322-L341

Keats avatar May 05 '25 08:05 Keats

It should be easier to implement, they look more like regular functions. For example: https://github.com/Keats/tera2/blob/master/tera/src/filters.rs#L322-L341

Since the round topic has been touched upon, I will make my suggestions regarding this filter. It would be logical to add the trunc method.

...
    Some("trunc") => Ok(((multiplier * val).trunc() / multiplier).into()),
...

azemlya avatar May 06 '25 07:05 azemlya

Sure that can be added

Keats avatar May 06 '25 07:05 Keats

For whatever reason, GitHub never notified me of this — I've got no problem adding it in if it hasn't already been done so upstream by @Keats or someone else

doamatto avatar May 31 '25 02:05 doamatto

Go for it

Keats avatar May 31 '25 06:05 Keats