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
Add urlescape to default filters #85
Conversation
If you like this, I can also add:
and
Let me know if it's worth writing pull requests for them. |
For a long time I was against url encode filters since they are encoding specific but now that everybody agrees on utf-8 as URLs it's probably fine. However I would love to see the filter accept dictionaries as well and automatically encoding them correctly. Also one name for the filter is enough :-) Lastly: needs tests. |
It has tests! What's wrong with them? |
What's wrong with having multiple names, especially when the function-name is so hard to remember like this one? It just makes it easier to use. Nonetheless, I have removed them and implemented your other difficult requests. It feels a bit like a trial by fire. How's it look now? |
Not sure how I missed them. Never mind then, but improved tests are always awesome :-)
Because filters are intended to be sensible defaults to hook others in and especially with urlencode it would be awful if someone who wants a different encoding behavior would have to override all the aliases for it as well. Especially if new aliases are introduced later. We only use aliases for core functionality that you don't want to change or is changeable from a separate API hook (for instance the autoescaping mirrors to the |safe, |e and |escape filters). It is encouraged to alias filters as necessary in your own application.
I'd rather have my contributors go the extra mile for a better final result than to pull things I regret later. Learned that the hard way.
I pulled it but had to rework the implementation for Python 3 compatibility. |
In theory I'm all for that but the problem is that strftime on Python 2.x is not unicode safe. Also it does not work for dates before 1900. That's the reason why this was never added and we documented the use of babel instead.
What's the use case for this? Not that I'm against such a filter but it seems fairly specific. |
Sorry about the Python 3 issues -- didn't think to test. And will try Your |
It'd be great if urlescape was included in the list of default filters, since it's so commonly needed. Here's a patch that passes all the test cases.