Last active
August 7, 2016 14:31
-
-
Save salex89/fed4c8fe91fcd2b96746671db4d35d65 to your computer and use it in GitHub Desktop.
Enabling Flask autoescape on files with *jinja2 extension. From http://stackoverflow.com/questions/13222925/how-do-i-enable-autoescaping-in-templates-with-a-jhtml-extension-in-flask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JHtmlEscapingFlask(Flask): | |
def select_jinja_autoescape(self, filename): | |
if filename is None: | |
return False | |
if filename.endswith('.jinja2'): | |
return True | |
return Flask.select_jinja_autoescape(self, filename) | |
app = JHtmlEscapingFlask(__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment