empy 1.3 -- Embed Python in template text as markup
nhodgson at bigpond.net.au
Sun Aug 25 03:09:42 CEST 2002
Erik Max Francis:
> empy is a system for embedding Python expressions and statements
> in template text; it takes empy source files, processes them, and
> produces output.
Have you considered in-place file regeneration? Rather than having an
input file which is processed into an output file, for some situations, I
prefer to use a file that is processed back into itself. This makes it
easier to experiment with the template file as it is the generated file and
ensures that you don't lose changes when you do tweak the generated file.
For example, in a make file there is
#++Autogenerated -- run src/LexGen.py to regenerate
#--Autogenerated -- end of automatically generated section
where "\*" indicates where the variable (specified externally) is
inserted and "\(" .. "\)" indicate the range repeated for each value. This
would be improved by allowing a way to specify the Python variable inline
rather than using "\*" and an external specification.
I currently use a specialised tool for this but feel it may be an
interesting direction to take a generic template tool in. The template tool
needs a way to find the range of the substitution and the definition and
there needs to be a way to hide these using comments from the main processor
of the file.
More information about the Python-list