From: Sebastian Spaeth Date: Mon, 26 Nov 2012 20:24:35 +0000 (+0100) Subject: Provide jinja2 urlencode filter X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=620e4e1b6e1f58d76b2bedb1d38495662ccd5af3;p=mediagoblin.git 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 --- 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