Skip to content

Allow sort filter to be case insensitive #967

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

doamatto
Copy link

@doamatto doamatto commented Apr 19, 2025

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

@cyckl
Copy link

cyckl commented Apr 19, 2025

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.

@doamatto
Copy link
Author

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

image

Before

image

@doamatto
Copy link
Author

doamatto commented May 3, 2025

@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 ^_^

@Keats
Copy link
Owner

Keats commented May 4, 2025

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.

@doamatto
Copy link
Author

doamatto commented May 5, 2025

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 ?

@Keats
Copy link
Owner

Keats commented May 5, 2025

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

@azemlya
Copy link

azemlya commented May 6, 2025

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()),
...

@Keats
Copy link
Owner

Keats commented May 6, 2025

Sure that can be added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a case_sensitive attribute to the sort filter Case-insensitive sort
4 participants