Re: Proposal: ptl_compile.register_preprocessor()

David Binger <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
Hi Graham,

> -from ptl_compile import compile_template, PTL_EXT
> +from quixote.ptl.ptl_compile import compile_template, PTL_EXT

Just checked in.


>  def parse(buf, filename='<string>'):
> +    for ext_proc in _external_preprocessors:
> +        buf = ext_proc(buf)
....



This change would not cause any problems as far as I know,
but I wonder if this will suffice.

As you know, but others may not, the ptl compiler uses a simple
source code transformation to convert templates into something
that can be parsed by the python parser, and then the compiler
applies some transformations to the parse tree to get the desired
template behavior.
It seems like your block structured code extension could follow
the same pattern if you registered a parse tree transformer in
addition to the preprocessor.
I would think that this would make it easier to support
block headers with multiple lines, comments, triple-quoted
strings, and the like.

Have you thought about that and decided against it?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.