Created
July 2, 2018 09:45
-
-
Save BlogBlocks/7049e03edecc8c52aa8bdcb85a9bd6b4 to your computer and use it in GitHub Desktop.
no filter named tojson modify jinja2 / filters,py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the error I got: | |
def join_path(self, template, parent): | |
\n in template() | |
\nTemplateAssertionError: no filter named 'tojson'\n | |
I tried different versions of jinja2, but the error remained. | |
ref: | |
https://github.com/pallets/jinja/pull/456/commits/7b4393dc86f17d67e1711cd9aa02ff40366519b4 | |
i was using pixiedust_node and it would not make a graph stating 'to_json' did not exist. | |
FYI - a window pops up and you must define the graph / plot parameters. It works fine | |
on Ubuntu 16.04 python2.7 using jinja2 VERSION 2.8 | |
in the file ..../jinja2/filters.py | |
Create the def do_json(value): function and add iot right above the def do_round(value, fuction | |
Example: | |
def do_json(value): | |
"""A filter that outputs Python objects as JSON""" | |
import json | |
return json.dumps(value) | |
-- this bottom function exists --- place do_json above it -- | |
def do_round(value, precision=0, method='common'): | |
"""Round the number to a given precision. The first | |
parameter specifies the precision (default is ``0``), | |
Then add ( 'to_json': do_json, ) to the definitions on the bottom of the page: | |
Example: | |
'wordcount': do_wordcount, | |
'wordcount': do_wordcount, | |
'wordwrap': do_wordwrap, | |
'wordwrap': do_wordwrap, | |
'xmlattr': do_xmlattr, | |
'xmlattr': do_xmlattr, | |
'to_json': do_json, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment