[IPython-dev] Template cells
Thomas Kluyver
takowl at gmail.com
Sat Dec 15 14:07:06 EST 2012
Revisiting a discussion from a few days ago, to get more input.
At one point, we were considering ways to interpolate variables from the
Python namespace into Markdown cells, using custom syntax and transferring
simple variables using the user_expressions field of execution messages.
Prompted by another discussion, I felt that this approach was quite
limiting, and a better approach would be to have a 'template cell',
designed like this:
- To the user, it works like a Markdown cell; when they leave the cell, the
editor is replaced by the rendered version of the contents.
- Since we now depend on Jinja2 for the notebook, we use the template
syntax from that, rather than reinventing a restricted template syntax
ourselves. This gives us things like loops in the templates.
- To render the cell, it is sent to the kernel as an execution request.
- The rendering uses our display infrastructure, so e.g. the HTML
representation of an object is preferred. But the template can override
this to get the plain text repr.
Open questions:
- Should the templates be in Markdown (for consistency with other rich-text
cells), or in HTML (which is more common in templating)?
- If in Markdown, should they be an automatic feature of Markdown cells
(i.e. the Javascript looks for template syntax, and decides to send it to
the kernel)? Or is that too surprising?
- How can we ensure notebooks with template cells work with current
versions of IPython, which don't know about them?
- Should there be any way to tell template cells to automatically
re-render, e.g. on a timer, or after another cell is executed?
Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20121215/824b924c/attachment.html>
More information about the IPython-dev
mailing list