# HG changeset patch # User Eddie Barraco # Date 1562303061 -7200 # Fri Jul 05 07:04:21 2019 +0200 # Node ID 1e0fe0b2b9efb4a6a13d05f221a842fea80ff502 # Parent 8442241be0a44f143bdd1af0a5c24ff6d8533d25 Use a context processor instead of filter diff --git a/cogito2/app.py b/cogito2/app.py --- a/cogito2/app.py +++ b/cogito2/app.py @@ -28,6 +28,9 @@ return render_template('show.html', article=article) -@app.template_filter('env') -def env_filter(key, default): - return environ.get(key, default) +@app.context_processor +def utility_processor(): + def get_env(key, default=None): + return environ.get(key, default) + return dict(get_env=get_env) + diff --git a/cogito2/templates/base.html b/cogito2/templates/base.html --- a/cogito2/templates/base.html +++ b/cogito2/templates/base.html @@ -9,7 +9,7 @@
-

The {{ 'OWNER_NAME' | env('OWNER NAME') }}'s blog

+

The {{ get_env('OWNER_NAME', 'XXX') }}'s blog