Skip to content

Commit

Permalink
Provide jinja2 urlencode filter
Browse files Browse the repository at this point in the history
Astonishingly, the great jinja2 does not provide a builtin urlquote filter,
although it is obviously needed. (jina1 had one) This is:
pallets/jinja#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 <Sebastian@SSpaeth.de>
  • Loading branch information
spaetz committed Dec 3, 2012
1 parent fd7c348 commit 620e4e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mediagoblin/tools/template.py
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 620e4e1

Please sign in to comment.