[IPython-dev] Template cells

Jason Grout jason-sage at creativetrax.com
Sat Dec 15 15:59:55 EST 2012


On 12/15/12 1:41 PM, Brian Granger wrote:
> I am aware of this implementation.  I just want to avoid the round
> tripping for Markdown.  We would loose an incredible amount of
> flexibility and responsiveness.  If JavaScript *couldn't* do things
> like render Markdown, that would be a different story, but JavaScript
> is more than capable of handling all of our need in this area.

We could emphasize the utility of no round-tripping for markdown by 
having a live preview, which in general is incredibly convenient for 
double-checking the output is what you intend.

On another of Thomas's points:
 > - To render the cell, it is sent to the kernel as an execution request.

I'm not sure if you meant we should form a valid execute request, but I 
think we should definitely *not* construct a string which is an execute 
request (i.e., we should not be constructing python code in the 
browser).  If we need the server to execute some code in a special way, 
there should be a message type or metadata indicating this, with the 
string, rather than trying to construct a python execute request.  In 
other words, we should not be doing something like:

s = 'HTML(template.render('+escape(code)+')';
kernel.execute_request(s);


A "template cell" is really a special case of an interactive widget.  I 
agree with Brian that we should examine this and some other ideas about 
getting/setting variable values (e.g., interactive widgets).  For 
example, I can imagine a render of a template cell knowing a few code 
expressions that it needs, and shipping those independently to the 
notebook for evaluation, then plugging in the results itself.  In fact, 
it could easily be arranged to have the IPython kernel push updates to 
the cell if IPython noticed that one of the variables changed values, so 
you'd get realtime updates.

Thanks,

Jason




More information about the IPython-dev mailing list