[IPython-dev] Template cells
Sat Dec 15 13:07:06 CST 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.
- 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
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev