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_displays_div_as_text(self, bokeh_model_page): para = Paragraph(text=text, css_classes=["foo"]) page = bokeh_model_page(para) el = page.driver.find_element_by_css_selector('.foo div p') assert el.get_attribute("innerHTML") == escape(text, quote=None) assert page.has_no_console_errors()
def test_quote_custom(self): assert bus.escape( "foo'bar", quote=('"'), ) == "foo'bar" assert bus.escape( "foo'bar", quote=("'"), ) == "foo'bar" assert bus.escape( 'foo"bar', quote=("'"), ) == 'foo"bar' assert bus.escape( 'foo"bar', quote=('"'), ) == "foo"bar"
def test_displays_div_as_text(self, bokeh_model_page): div = Div(text=text, css_classes=["foo"], render_as_text=True) page = bokeh_model_page(div) el = page.driver.find_element_by_css_selector('div.foo div div') assert el.get_attribute("innerHTML") == escape(text, quote=None) assert page.has_no_console_errors()
def test_displays_div_as_text(self, bokeh_model_page): div = Div(text=text, css_classes=["foo"], render_as_text=True) page = bokeh_model_page(div) el = page.driver.find_element_by_css_selector('.foo div') assert el.get_attribute("innerHTML") == escape(text, quote=None) assert page.has_no_console_errors()
def test_gt(self): assert bus.escape("foo>bar") == "foo>bar"
def test_lt(self): assert bus.escape("foo<bar") == "foo<bar"
def test_amp(self): assert bus.escape("foo&bar") == "foo&bar"
def test_quote_False(self): assert bus.escape("foo'bar", quote=False) == "foo'bar" assert bus.escape('foo"bar', quote=False) == 'foo"bar'
def test_quote_custom(self): assert bus.escape("foo'bar", quote=('"'),) == "foo'bar" assert bus.escape("foo'bar", quote=("'"),) == "foo'bar" assert bus.escape('foo"bar', quote=("'"),) == 'foo"bar' assert bus.escape('foo"bar', quote=('"'),) == "foo"bar"
def test_default_quote(self): assert bus.escape("foo'bar") == "foo'bar" assert bus.escape('foo"bar') == "foo"bar"