skip to navigation
skip to content

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) '
12
34
' >>> 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 10:24:13 12KB 386
flexable-0.3dev.tar.gz (md5) Source 2007-07-18 10:24:12 6KB 273

Log in to rate this package.