-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It looks like the secretary tool doesn't work with the latest Jinja #73
Comments
I second this, exact same symptoms in a project I'm working on, jinja >3 doesn't work and gives "jinja2.nodes.EvalContext object at ..." but works fine after downgrade. I used the same version as M-Startc to be sure (Your comment saved me btw, thank you !). Python 3.8 as well. |
same |
In addition to my PR #74, if you can't apply it, you should be able to prevent the issue by passing a custom environment: from secretary import Renderer, UndefinedSilently, pad_string
from jinja2 import Environment
# markupsafe is a dependency of jinja2.
from markupsafe import Markup
def finalize_value(value):
if isinstance(value, Markup):
return value
# get_escaped_var_value is a static method.
return Markup(Renderer.get_escaped_var_value(value))
environment = Environment(undefined=UndefinedSilently,
autoescape=True,
finalize=finalize_value)
environment.filters['pad'] = pad_string
environment.globals['SafeValue'] = Markup
renderer = Renderer(environment)
# Those are standard method, we need to have a proper instance for them to work.
environment.filters['markdown'] = renderer.markdown_filter
environment.filters['image'] = renderer.image_filter I haven't tested it but it should work and provide you the same level of functionality. |
@Jenselme tested and it works, thanks! |
You can also patch jinja before importing secretary: import jinja2
import markupsafe
jinja2.Markup = markupsafe.Markup
jinja2.evalcontextfilter = jinja2.pass_context
import secretary |
I have Jinja2=3.0.1 and I see "jinja2.nodes.EvalContext object at ...." in the document fields instead of the needed content.
I could get the secretary tool working after Jinja2 downgrade to 2.11.2
I use python 3.8 in my project and use the tool with OpenOffice odt document
Thank you
The text was updated successfully, but these errors were encountered: