#6135: Introduce a short-cut for template filters that has needs_autoescape = 
True
---------------------------------+------------------------------------
     Reporter:  anonymous        |                    Owner:  Chinmoy
         Type:  New feature      |                   Status:  assigned
    Component:  Template system  |                  Version:  dev
     Severity:  Normal           |               Resolution:
     Keywords:  autoescape       |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  1                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by Carlton Gibson):

 I think we should `wontfix` this. Copying my
 [https://github.com/django/django/pull/14784#pullrequestreview-898610549
 comment from the PR]:

 > I have to say that after 14 years I think we should probably close this
 as wontfix. 😬
 >
 > I think the new decorator is likely to cause more confusion that it'll
 solve.
 >
 > Specifically, it's only going to be appropriate for filters already
 marked @stringfilter — that's fine, in theory, but that's not documented
 at all — and it's going to be anything but clear to document — and we're
 going to see a whole load of reports saying @autoescape_aware doesn't work
 with my filter.
 >
 > There's already a way to do this, and the proposed decorator isn't
 sufficiently robust to cover all cases.
 >
 > Also, as evidenced by those 14 years, I'm not convinced the saving is
 all that great:
 >
 >     if autoescape:
 >         esc = conditional_escape
 >     else:
 >         esc = lambda x: x
 > … OK, yes. It's slightly repetitive. If it really bothered me I could
 write a make_escape() factory function to remove the duplication. But, on
 the other hand, it's clear: there's no question of what the behaviour is,
 and I don't have to go looking into the source to see how the parameters
 get applied.
 >
 > Summary, I'm not at all convinced the proposed decorator pays its way.
 > 🤔

-- 
Ticket URL: <https://code.djangoproject.com/ticket/6135#comment:22>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017f59d0d3df-3b321e06-67f6-4542-90a0-8d0fd50248e0-000000%40eu-central-1.amazonses.com.

Reply via email to