Idea for pure-python templates using AST.
Tim Roberts
timr at probo.com
Tue Aug 16 20:39:39 EDT 2011
"Paul Wray" <paul.wray at det.nsw.edu.au> wrote:
>
>Ive had what I think is a great idea for pure-python templates (I can almost
>hear the groans, bear with me...)
>...
>The idea:
>Python syntax allows a statement to be a bare literal or identifier. These
>have no effect on the program.
>...
>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>'
This is essentially how the original CherryPy version 1 web framework
worked. In the end, I think it was decided that this represented too
much of a mix of processing and presentation, and CherryPy 2 and 3 use a
different scheme.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list