Flask Snippets

Override which templates are autoescaped

Posted by Dag Odenhall on 2011-01-29 @ 00:28 and filed in Template Tricks

from flask import Flask

class JHtmlEscapingFlask(Flask):

    def select_jinja_autoescape(self, filename):
        if filename.endswith('.jhtml'):
            return True
        return Flask.select_jinja_autoescape(self, filename)

app = JHtmlEscapingFlask(__name__)

This snippet by Dag Odenhall can be used freely for anything you like. Consider it public domain.