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)