Flask Snippets

Override which templates are autoescaped

By Dag Odenhall 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.