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 <Sebastian@SSpaeth.de>
This commit is contained in:
parent
fd7c348415
commit
620e4e1b6e
@ -17,6 +17,8 @@
|
|||||||
from math import ceil
|
from math import ceil
|
||||||
import jinja2
|
import jinja2
|
||||||
from babel.localedata import exists
|
from babel.localedata import exists
|
||||||
|
from werkzeug.urls import url_quote_plus
|
||||||
|
|
||||||
from mediagoblin import mg_globals
|
from mediagoblin import mg_globals
|
||||||
from mediagoblin import messages
|
from mediagoblin import messages
|
||||||
from mediagoblin.tools import common
|
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['app_config'] = mg_globals.app_config
|
||||||
template_env.globals['global_config'] = mg_globals.global_config
|
template_env.globals['global_config'] = mg_globals.global_config
|
||||||
|
|
||||||
|
template_env.filters['urlencode'] = url_quote_plus
|
||||||
|
|
||||||
if exists(locale):
|
if exists(locale):
|
||||||
SETUP_JINJA_ENVS[locale] = template_env
|
SETUP_JINJA_ENVS[locale] = template_env
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user