Flask Snippets

Snippets are unofficial and unmaintained.

This is an archived view of user-submitted snippets. Despite being hosted on the Flask site, they are not official. No Flask maintainer has curated or checked the snippets for security, correctness, or design.

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.