From ce5aeb40e5fd8c24868a010b9be892cc8cb4ac87 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 1 Apr 2017 20:10:37 -0500 Subject: [PATCH] Add basic jinja filter, for test.. --- hotcooler/jinja_filters.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 hotcooler/jinja_filters.py diff --git a/hotcooler/jinja_filters.py b/hotcooler/jinja_filters.py new file mode 100644 index 0000000..bc4e774 --- /dev/null +++ b/hotcooler/jinja_filters.py @@ -0,0 +1,18 @@ + +from jinja2 import contextfilter +from pyramid.threadlocal import get_current_request +from pyramid.url import static_url + + +@contextfilter +def static_url_filter(ctx, path, **kw): + """A filter from ``path`` to a string representing the absolute URL. + This filter calls :py:func:`pyramid.url.static_url`. + + Example:: + + + + """ + request = ctx.get('request') or get_current_request() + return static_url(path, request, **kw)