Introduce a short-cut for template filters that has needs_autoescape = True
|Reported by:||anonymous||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
After the autoescaping was introduced I had to rewrite all filters to comform new requirements: put is_safe=True and needs_autoescape=True where needed.
I have written about 25 filters that have needs_autoescape=True and absolutely of them contained contained the same strings
def filter(text, autoescape=None): if autoescape: esc = conditional_escape else: esc = lambda x: x text = esc(text) # Then goes the part which is different for all filters # # return mark_safe(result)
I have checked the filters in django. All the same.
I think it is way to much of writting.
I propose to split property needs_autoescape = True on two properties:
needs_manual_autoescape = True, then Do all the stuff above, manually.
needs_autoescape = True, then all above steps will do template system for user. All this thinks can do a simple decorator as well.
Change History (8)
comment:1 Changed 9 years ago by
|Patch needs improvement:||unset|