예제 #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"})