Ticket #14057: 14057-context-parameter.diff

File 14057-context-parameter.diff, 611 bytes (added by Will Hardy, 14 years ago)

Allowing a callable to be passed to Context, providing custom autoescape

  • django/template/__init__.py

     
    828828    value = localize(value, use_l10n=context.use_l10n)
    829829    value = force_unicode(value)
    830830    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
    831         return escape(value)
     831        if callable(context.autoescape):
     832            return context.autoescape(value)
     833        else:
     834            return escape(value)
    832835    else:
    833836        return value
    834837
Back to Top