def html_for_render_items(docs_json, render_items, template=None, template_variables={}): json_id = make_id() json = escape(serialize_json(docs_json), quote=False) json = wrap_in_script_tag(json, "application/json", json_id) script = wrap_in_script_tag(script_for_render_items(json_id, render_items)) context = template_variables.copy() context.update( dict( title='', plot_script=json + script, docs=render_items, base=NB_TEMPLATE_BASE, macros=MACROS, )) if len(render_items) == 1: context["doc"] = context["docs"][0] context["roots"] = context["doc"].roots if template is None: template = NB_TEMPLATE_BASE elif isinstance(template, string_types): template = _env.from_string("{% extends base %}\n" + template) return template.render(context)
def test_render(self): assert bew.wrap_in_script_tag("code\nmorecode") == """
def test_render(self): assert bew.wrap_in_script_tag("code\nmorecode") == """