Revisiting a discussion from a few days ago, to get more input.<br><br>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.<br>
<br>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:<br><br>- 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.<br>
- 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.<br>- To render the cell, it is sent to the kernel as an execution request.<br>
- 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.<br><br>Open questions:<br>- Should the templates be in Markdown (for consistency with other rich-text cells), or in HTML (which is more common in templating)?<br>
- 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?<br>- How can we ensure notebooks with template cells work with current versions of IPython, which don't know about them?<br>
- Should there be any way to tell template cells to automatically re-render, e.g. on a timer, or after another cell is executed?<br><br>Thanks,<br>Thomas<br>