From 620e4e1b6e1f58d76b2bedb1d38495662ccd5af3 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 26 Nov 2012 21:24:35 +0100 Subject: [PATCH] Provide jinja2 urlencode filter Astonishingly, the great jinja2 does not provide a builtin urlquote filter, although it is obviously needed. (jina1 had one) This is: https://github.com/mitsuhiko/jinja2/issues/17 Provide an urlencode filter, based on werkzeug's url_quote_plus function. This is dead easy to implement and gives us all the freedom we want. Signed-off-by: Sebastian Spaeth --- mediagoblin/tools/template.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index 6f603bab..cb556e4c 100644 --- a/mediagoblin/tools/template.py +++ b/mediagoblin/tools/template.py @@ -17,6 +17,8 @@ from math import ceil import jinja2 from babel.localedata import exists +from werkzeug.urls import url_quote_plus + from mediagoblin import mg_globals from mediagoblin import messages from mediagoblin.tools import common @@ -62,6 +64,8 @@ def get_jinja_env(template_loader, locale): template_env.globals['app_config'] = mg_globals.app_config template_env.globals['global_config'] = mg_globals.global_config + template_env.filters['urlencode'] = url_quote_plus + if exists(locale): SETUP_JINJA_ENVS[locale] = template_env -- 2.25.1