473,480 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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:

http://www.simplistix.co.uk/software/python/twiddler

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

http://groups.google.com/group/twiddler

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('''<body>
.... <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=PlainText)
>>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
Dec 16 '06 #1
0 927

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2083
by: Roger Jack | last post by:
I have just finished reading Code Generation In Action which uses Ruby for code generation. I would like to use Python instead. Is Cheetah the best tool to use for templating source code files and...
31
2042
by: Leif K-Brooks | last post by:
I'm planning to start on a fairly large web application, most likely using mod_python. I recently wrote a fairly small (but real-world useful) web app with it, and all of those req.write()s made...
3
1420
by: Chris Stiles | last post by:
Hi -- Does anyone have any recommendations for simple web templating systems for python that also allow execution of python code within the the templates themselves ? So far I'm using...
18
4930
by: pkassianidis | last post by:
Hello everybody, I am in the process of writing my very first web application in Python, and I need a way to generate dynamic HTML pages with data from a database. I have to say I am...
13
1377
by: qscomputing | last post by:
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...
6
1169
by: Paolo Pantaleo | last post by:
I am working on this: I have a text file, containig certain section in the form <?py python code here py?> I parse the text file and substitute the python code with its result . It...
7
1602
by: Paul | last post by:
I have been coding apps with PHP for several years. But I am getting more involved in larger and more complicated PHP applications and want to use best practices. I use Eclipse's PHP IDE. I...
5
892
by: Thomas Troeger | last post by:
Dear all, I've written a program that parses a string or file for embedded python commands, executes them and fills in the returned value. The input might look like this: process id: $$return...
10
1692
by: Terrence Brannon | last post by:
Hello, The most common way of dynamically producing HTML is via template engines like genshi, cheetah, makotemplates, etc. These engines are 'inline' --- they intersperse programming...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.