Getting Started with Python Chameleon Templates +++++++++++++++++++++++++++++++++++++++++++++++ :Posted: 2009-12-01 12:36 :Tags: Python, Pylons :Headline: Get started with Chameleon Templates using pure Python and no Zope dependencies. You can then use TAL and more. Here's the code you need which is missing from the main docs: Save this as ``helloworld.pt``: ::
Designer sees this.
""" ) result = template(user_message='User sees this') The result is: ::User sees this
.. note :: The reason I'm interested in this is that I've stopped using templating languages in my code. Instead I use static HTML files as templates and I just replace certain parts with Python-generated code. (This isn't as nasty as it sounds because the static HTML files are in Dreamweaver format which supports Library Items for common elements). I therefore have no need for any inheritance features because I have a different Dreamweaver template for each page layout (made consistent with Library Items) but I would like a way for Python to be able to parse some of that HTML so that designers can work with it but so that I don't have to write all my template fragments in Python. TAL is a good fit for this as I can just use TAL-formatted HTML in the editable regions and Chameleon supports TAL. I'm not using METAL and the like though. Further reading: * http://chameleon.repoze.org/ * http://wiki.pylonshq.com/display/pylonscookbook/QuickWiki+with+Chameleon * http://jimmyg.org/work/code/dreamweavertemplate/index.html