A new text templating system for python!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Withers

    #1

    A new text templating system for python!

    Hi All,

    I'm proud to announce that after almost a year's development, the first
    public release of Twiddler is available!

    Twiddler is a simple but flexible templating system for dynamically
    generating textual output.

    The key features are:

    - No need to learn a templating language.

    - As simple as possible while still catering for all possible templating
    operations.

    - Configurable input parsing so source can be html, xml, plain text or
    anything you write an input parser for.

    - Configurable output rendering so output can be rendered to a unicode
    string, an email, or anything you write an output renderer for.

    You can find out more and download from here:



    If you wish to ask questions, pass judgement or get help, please do so
    in the following mailing list:



    This is the first public release, so I'm looking for help with the
    following:

    - Finding anything that should be possible in a templating system but
    isn't with Twiddler

    - Packaging it up for easier distribution. I know nothing about eggs,
    distutils, etc, and so could do with help to package Twiddler so that
    it can be more easily installed.

    Finally, here's a couple of quick examples:
    >>from twiddler import Twiddler
    >>t = Twiddler('''<bo dy>
    .... <div id="title">A title</div>
    .... <select name="items">
    .... <option id="item">An item</option>
    .... </select>
    .... </body>''')
    >>t['title'].replace('My title')
    >>r = t['item'].repeater()
    >>for i in range(1,4):
    .... r.repeat('Item '+str(i),value= i,name=False)
    >>print t.render()
    <body>
    <div id="title">My title</div>
    <select name="items">
    <option id="item" value="1">Item 1</option>
    <option id="item" value="2">Item 2</option>
    <option id="item" value="3">Item 3</option>
    </select>
    </body>
    >>from twiddler.input. plaintext import PlainText
    >>t = Twiddler('''To: $to
    .... <item>An item</item>
    .... ''',input=Plain Text)
    >>t['to'].replace('John Smith')
    >>r = t['item'].repeater()
    >>for i in range(1,4):
    .... r.repeat('Item '+str(i),value= i,name=False)
    >>print t.render()
    To: John Smith
    Item 1
    Item 2
    Item 3

    Thanks for reading this far, I hope you enjoy it!

    cheers,

    Chris

    --
    Simplistix - Content Management, Zope & Python Consulting
    - http://www.simplistix.co.uk
Working...