Пример #1
0
def render_slide(file, templates, partials):
	header = parse_header(file)
	slide_src = header["src"]
	template_name = header.get("context", {}).get("template", None)
	template_src = templates.get(template_name, None)

	template_config = {"partial": partials}

	if template_src is not None:
		# bind to contents variable
		template_config["contents"] = slide_src
		eco_ctx = eco.context_for(template_src)
	else:
		eco_ctx = eco.context_for(slide_src)

	# merge with header context dictionary
	return eco_ctx.call("render", dict(template_config, **header["context"]))
Пример #2
0
def render_slide(file, templates, partials):
    header = parse_header(file)
    slide_src = header["src"]
    template_name = header.get("context", {}).get("template", None)
    template_src = templates.get(template_name, None)

    template_config = {"partial": partials}

    if template_src is not None:
        # bind to contents variable
        template_config["contents"] = slide_src
        eco_ctx = eco.context_for(template_src)
    else:
        eco_ctx = eco.context_for(slide_src)

    # merge with header context dictionary
    return eco_ctx.call("render", dict(template_config, **header["context"]))
Пример #3
0
def test_runtime_error():
    context = eco.context_for("Hello <% throw 'foo' %>")
    try:
        context.call("render")
    except execjs.ProgramError:
        pass
Пример #4
0
def test_context_for():
    context = eco.context_for("Hello <%= @name %>")
    assert "Hello " == context.call("render")
    assert "Hello Sam" == context.call("render", {"name": "Sam"})
Пример #5
0
def test_runtime_error():
    context = eco.context_for("Hello <% throw 'foo' %>")
    try:
        context.call("render")
    except execjs.ProgramError:
        pass
Пример #6
0
def test_context_for():
    context = eco.context_for("Hello <%= @name %>")
    assert "Hello " == context.call("render")
    assert "Hello Sam" == context.call("render", {"name": "Sam"})