Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Template engine with simple data structure

Project Description
`flexable` is template engine with simple data structure.
That is made up of str, unicode, dict, tuple, list and Element.

usage
merge structured values to xhtml template.

>>> t = Template()
>>> t.fromstring("<div/>")
>>> str(t)
'<div/>'

>>> t.merge('hello')
>>> str(t)
'<div>hello</div>'

>>> t = Template()
>>> t.fromstring("<div><span class='y'/></div>")
>>> t.merge({'y':['1', '2']})
>>> str(t)
'<div><span class="y">1</span><span class="y">2</span></div>'

>>> t = Template()
>>> t.fromstring("<div><span class='y'/></div>")
>>> t.merge({'y':[({'@id':'m1'}, '1'),
... ({'@id':'m2'}, '2')]})
>>> str(t)
'<div><span class="y" id="m1">1</span><span class="y" id="m2">2</span></div>'

>>> t.fromstring("<div><div class='box'><span class='x'/><span
class='y'/></div></div>")
>>> t.merge({'box':[{'x':'1', 'y':'2'},
... {'x':'3', 'y':'4'}]})
>>> str(t)
'<div><div class="box"><span class="x">1</span><span
class="y">2</span></div><div class="box"><span class="x">3</span><span
class="y">4</span></div></div>'

>>> t.fromstring("<div/>")
>>> t.merge(ET.Element('span'))
>>> str(t)
'<div><span/></div>'

To use flexable as template engine for wsgi application, you can use
flexable.plugin:FlexablePlugin.
And that is python.template_engine entry point.

Example on TurboGears

controllers.py::

@expose(template="flexable:flexable_example.templates.example")
def example(self):
return dict(message="This is flexable message.",
contents=""" This is main contents from controller.
flexable is merge values to given html template with class attribute.
""")

flexable_example/templates/example.html::

&lt;?xml version="1.0"?>
&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;body>
&lt;h1>Flexable Template&lt;/h1>
&lt;span class="message">&lt;/span>
&lt;p class="contents">&lt;/p>
&lt;span class="widget"/>
&lt;/body>
&lt;/html>

you get:

&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;body>
&lt;h1>Flexable Template&lt;/h1>
&lt;span class="message">This is flexable message.&lt;/span>
&lt;p class="contents"> This is main contents from controller.
flexable is merge values to given html template with class attribute.
&lt;/p>
&lt;/body>
&lt;/html>
Release History

Release History

This version
History Node

0.3dev

History Node

0.2dev

History Node

0.1.1dev

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
flexable-0.3dev-py2.5.egg (12.9 kB) Copy SHA256 Checksum SHA256 2.5 Egg Jul 18, 2007
flexable-0.3dev.tar.gz (6.2 kB) Copy SHA256 Checksum SHA256 Source Jul 18, 2007

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting