Add basic jinja filter, for test..
This commit is contained in:
parent
52fe782e14
commit
ce5aeb40e5
18
hotcooler/jinja_filters.py
Normal file
18
hotcooler/jinja_filters.py
Normal file
|
@ -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::
|
||||
|
||||
<link rel="stylesheet" href="{{'yourapp:static/css/style.css'|static_url}}" />
|
||||
|
||||
"""
|
||||
request = ctx.get('request') or get_current_request()
|
||||
return static_url(path, request, **kw)
|
Loading…
Reference in a new issue