Idea for pure-python templates using AST.
paulwray111111 at gmail.com
Tue Aug 16 21:02:40 EDT 2011
On Aug 17, 5:23 am, Irmen de Jong <ir... at -NOSPAM-xs4all.nl> wrote:
> On 16-08-11 13:33, Paul Wray wrote:
> > The idea:
> > Python syntax allows a statement to be a bare literal or identifier.
> > These have no effect on the program.
> > So the function below is legal python:
> > def myFunc():
> > 'a'
> > x = 45
> > 'b'; 'c'; x
> > So is this (within the appropriate class context of course):
> > def body(self, r):
> > '<h1>'; self.heading; '</h1>'
> > '<ul>'
> > for itm in self.items:
> > '<li>'; itm; '</li>'
> > '</ul>'
> Looks very similar to PTL what Quixote uses:http://www.quixote.ca/overview/paper.html
> (never used it though, and I doubt Quixote used ASTs)
Thanks. Yes it looks much the same, and it does use AST. This from the
"""Compile a PTL template.
First template function names are mangled, noting the template type.
Next, the file is parsed into a parse tree. This tree is converted
a modified AST. It is during this state that the semantics are
by adding extra nodes to the tree. Finally bytecode is generated
the compiler package.
More information about the Python-list