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

Simple API for in-memory templates #674

wants to merge 2 commits into
base: master


None yet
2 participants
Copy link

takluyver commented Sep 13, 2017

Closes #673.

The new API is a method exporter.use_string_template(s), which you pass the string template into.

Example to use it with a subclass:

import sys
from nbconvert.exporters import HTMLExporter

{%- extends 'full.tpl' -%}

{%- block markdowncell -%}
<div style="background-color: hsl(85, 86%, 76%);">
{{ super() }}
{%- endblock markdowncell -%}

class PopExporter(HTMLExporter):
    def __init__(self, **kwargs):

if __name__ == '__main__':
    out, res = PopExporter().from_filename(sys.argv[1])
    with open('pops.html', 'w') as f:

This comment has been minimized.

Copy link

mpacer commented Sep 13, 2017

I had a slightly different API in mind, and I'm going to try to write it from scratch but if I find myself using enough patterns similar to yours I'll just rebase it off of this branch.

@takluyver takluyver closed this Sep 19, 2017

@mpacer mpacer added this to the 5.4 milestone Oct 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment