flexable 0.3dev
Template engine with simple data structure
`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("")
>>> str(t)
''
>>> t.merge('hello')
>>> str(t)
'hello'
>>> t = Template()
>>> t.fromstring("")
>>> t.merge({'y':['1', '2']})
>>> str(t)
'12'
>>> t = Template()
>>> t.fromstring("")
>>> t.merge({'y':[({'@id':'m1'}, '1'),
... ({'@id':'m2'}, '2')]})
>>> str(t)
'12'
>>> t.fromstring("")
>>> t.merge({'box':[{'x':'1', 'y':'2'},
... {'x':'3', 'y':'4'}]})
>>> str(t)
'1234'
>>> t.fromstring("")
>>> t.merge(ET.Element('span'))
>>> str(t)
''
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::
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h1>Flexable Template</h1>
<span class="message"></span>
<p class="contents"></p>
<span class="widget"/>
</body>
</html>
you get:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h1>Flexable Template</h1>
<span class="message">This is flexable message.</span>
<p class="contents"> This is main contents from controller.
flexable is merge values to given html template with class attribute.
</p>
</body>
</html>
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| flexable-0.3dev-py2.5.egg (md5) | Python Egg | 2.5 | 2007-07-18 | 12KB | 861 |
| flexable-0.3dev.tar.gz (md5) | Source | 2007-07-18 | 6KB | 714 | |
- Author: Atsushi Odagiri
- Keywords: wsgi template xml
- License: BSD
-
Categories
- Development Status :: 3 - Alpha
- Environment :: Web Environment
- Intended Audience :: Developers
- License :: OSI Approved :: BSD License
- Operating System :: OS Independent
- Programming Language :: Python
- Topic :: Text Processing
- Topic :: Text Processing :: Markup :: HTML
- Topic :: Text Processing :: Markup :: XML
- Package Index Owner: aodag
- DOAP record: flexable-0.3dev.xml
