From f6a0026d6740831fc3034f4076c607005eb3ffcf Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 3 Oct 2019 13:00:32 +0100 Subject: [PATCH] Add extension initialisation in app init --- app/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index 81477c346..e9f1bc698 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -7,6 +7,7 @@ from numbers import Number from time import monotonic import ago +import jinja2 from flask import ( current_app, flash, @@ -22,6 +23,7 @@ from flask.globals import _lookup_req_object, _request_ctx_stack from flask_login import LoginManager, current_user from flask_wtf import CSRFProtect from flask_wtf.csrf import CSRFError +from govuk_frontend_jinja.flask_ext import init_govuk_frontend from itsdangerous import BadSignature from notifications_python_client.errors import HTTPError from notifications_utils import formatters, logging, request_helper @@ -116,6 +118,9 @@ def create_app(application): init_app(application) + init_govuk_frontend(application) + init_jinja(application) + for client in ( # Gubbins @@ -701,3 +706,13 @@ def add_template_filters(application): id_safe, ]: application.add_template_filter(fn) + + +def init_jinja(application): + repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + template_folders = [ + os.path.join(repo_root, 'app/templates'), + os.path.join(repo_root, 'node_modules/govuk-frontend'), + ] + jinja_loader = jinja2.FileSystemLoader(template_folders) + application.jinja_loader = jinja_loader