Skip to content

Allow sort filter to be case insensitive#967

Open
doamatto wants to merge 3 commits into
Keats:masterfrom
doamatto:sort-case-sensitive
Open

Allow sort filter to be case insensitive#967
doamatto wants to merge 3 commits into
Keats:masterfrom
doamatto:sort-case-sensitive

Conversation

@doamatto

@doamatto doamatto commented Apr 19, 2025

Copy link
Copy Markdown

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

cyckl commented Apr 19, 2025

Copy link
Copy Markdown

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
Copy Markdown
Author

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

image

Before

image

@doamatto

doamatto commented May 3, 2025

Copy link
Copy Markdown
Author

@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

Keats commented May 4, 2025

Copy link
Copy Markdown
Owner

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

doamatto commented May 5, 2025

Copy link
Copy Markdown
Author

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

Keats commented May 5, 2025

Copy link
Copy Markdown
Owner

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

azemlya commented May 6, 2025

Copy link
Copy Markdown

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

Keats commented May 6, 2025

Copy link
Copy Markdown
Owner

Sure that can be added

@doamatto

Copy link
Copy Markdown
Author

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

@Keats

Keats commented May 31, 2025

Copy link
Copy Markdown
Owner

Go for it

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