Hi everyone,
With Jinja2, it’s possible to define custom filters, like so:
def datetimeformat(value, format='%H:%M / %d-%m-%Y'):
return value.strftime(format)
And then you can set your environment like so:
environment.filters['datetimeformat'] = datetimeformat
then in your template, you can do something like:
publication date: {{ article.pub_date|datetimeformat('%d-%m-%Y') }}
Is it possible to do this with apps launched by bokeh serve? In my case, I’ve used the dash
dashboard example from the bokeh github repository, and added to my main.py
from jinja2 import Environment, FileSystemLoader
from templating import format_currency
root = os.path.dirname(os.path.abspath(__file__))
env = Environment( loader= FileSystemLoader(root) )
env.filters["format_currency"] = format_currency
However it doesn’t seem like it works. When I start the app, I get ERROR: no filter named 'format_currency'
. Am I missing something or is it not possible to do that at this time?