Non-web-based templating system

Fuzzyman fuzzyman at gmail.com
Tue May 2 05:27:09 EDT 2006


qscomputing at gmail.com wrote:
> Hi,
>
> I'm creating a small application in Python that uses lists and
> dictionaries to create a rudimentary database. I'd like to create some
> "fill-in-the-blanks" reports from this data, ideally by taking an RTF
> or plaintext file as a template and replacing placeholder tags with my
> data.
> Are there any good pre-written systems that would allow me to do this?
>

Another option is the 'embedded_code.py' module used by `Firedrop2
<http://www.voidspace.org.uk/python/firedrop2/>`_ and `rest2web
<http://www.voidspace.org.uk/python/rest2web/>`_.

It takes a text string as input and a namespace (dictionary) as input
and returns a text string.

It replaces single placeholders of the form :

    <% name %>

It also executes chunks of embedded code in the namespace, and replaces
them with whatever the code prints to stdout. These are of the form :

    <#
        print name
        if name2.startswith('something'):
            print name2
    #>

This is very useful for simple templating.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/shareware.shtml


> Thanks,
>   - QS Computing.




More information about the Python-list mailing list