Skip to content
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

Update Deprecated Jinja Calls in Report Generation #259

Merged
merged 4 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pygsti/report/merge_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import webbrowser as _webbrowser
from pathlib import Path

from markupsafe import Markup

from pygsti.baseobjs.verbosityprinter import VerbosityPrinter as _VerbosityPrinter
from pygsti.tools import timed_block as _timed_block

Expand Down Expand Up @@ -464,13 +466,16 @@ def offline_file(filename):
"""Embed an offline file's contents directly in the document, in a script tag."""
# XXX we gotta find a better way, this is so wild dude
contents = offline_loader.get_source(env, filename)[0]
return markupsafe.Markup(contents)

return Markup(contents)


@jinja_filter
@jinja2.pass_eval_context
def render(eval_ctx, value):
html = _render_as_html(value, render_options or {}, link_to)
return markupsafe.Markup(html) if eval_ctx.autoescape else html

return Markup(html) if eval_ctx.autoescape else html

return env

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'evolutionary_optimization': ['deap'],
'report_pickling': ['pandas'],
'report_pdf_figures': ['matplotlib'],
'html_reports': ['jinja2'],
'html_reports': ['jinja2', 'MarkupSafe'],
'notebooks': [
'ipython',
'notebook'
Expand Down