From dd3182f3856a0a2044f9d6067b7cb54c0bcf3720 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 29 Nov 2022 23:22:46 +0100 Subject: [PATCH] add missing files --- environ.py | 14 ++++++++++++++ filters.py | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 environ.py create mode 100644 filters.py diff --git a/environ.py b/environ.py new file mode 100644 index 0000000..ce636f0 --- /dev/null +++ b/environ.py @@ -0,0 +1,14 @@ +# https://github.com/kolypto/j2cli#customization + +# http://jinja.pocoo.org/docs/2.10/api/#jinja2.Environment +def j2_environment_params(): return dict( + autoescape = True, + trim_blocks = True, + lstrip_blocks = True, + keep_trailing_newline = True, + extensions = ("jinja2.ext.do", "jinja2.ext.loopcontrols"), +) + +def j2_environment(env): return (env.globals.update( + my_function = lambda v: 'my function says "{}"'.format(v), +), env)[1] diff --git a/filters.py b/filters.py new file mode 100644 index 0000000..687ca86 --- /dev/null +++ b/filters.py @@ -0,0 +1,6 @@ +#from jinja2 import Markup +import json + +def to_json(obj): + #return Markup(json.dumps(obj)) + return json.dumps(obj)