-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Built-in filters #18
Comments
Thank you, this is really useful! Note that I'm anything but committed to necessarily copying over all the built-in filters; some of these probably don't make much sense with Rust; others might need an amount of complexity that I'm not sure would make sense to always carry in Askama. But the simple ones probably should all join, and trim is a good example of that. @mitsuhiko, any thoughts about how you selected whether things could go in the built-ins in Jinja? Any that you regret adding? |
As of 2017 I'm quite happy with the filters and tests that exist. The ones I feel are unnecessary are
|
BTW. I do still plan on porting |
@djc: what do you think
Upd: added https://github.com/djc/askama/pull/39, let's continue API discussion there |
@djc: could you please clean up the list to leave things you think make sense as filters in askama, so it's easier for contributors to start working on them? |
@defyrlt good to see your enthusiasm for contributing! Personally, I mostly prefer that people mention filters that they actually have a use for in their Rust code, rather than us just blindly implementing all the filters for Jinja compatibility. That said, some other high-level guidance:
|
The following filters are not viable in Rust: attr, default, dictsort, groupby, map, pprint, rejectattr, selectattr, sum and xmlattr. |
Could you explain for each of those why you think they aren't viable, please? |
It's because they are filters for Python dictionaries and it has no sense in Rust. |
Why not? Wouldn't the same thing be relevant for |
Since templates live within the response function, allocating it inside the heap is a serious performance issue. |
It typically won't be the template allocating: the template is just using an allocated |
Hi, I can see that And is there any doc about how to write custom filters (especially for numbers)? Thanks! |
And I noticed that the |
I made some changes in 0.9 to make the extra dependencies pulled in by some of the filter implementations optional. In the case of Defining your own filters is explained in https://docs.rs/askama/0.9.0/askama/#filters, is that explanation not clear enough? |
Tracking down the built-in filters available in jinja2. So that people can pick these to contribute. Feel free to add / remove items.
ref: https://jinja.palletsprojects.com/en/2.11.x/templates/#builtin-filters
The text was updated successfully, but these errors were encountered: