Pure python html templating using with statements
gist.github.com
gist.github.com
Weby Templates are used in production on websites that have garnered over 500,000 uniques a month. They are incredibly easy to work with. They are the "templates for lazy people". They have 3 main benefits:
* easier * faster * more flexible
* The main codebase is implemented in 100 source lines of code.
* Extensive libraries only add just a couple hundred other lines of code.
* It is simple.
* It ensures that all tags have closing tags.
* It is compiled and fast.
* It is unicode compliant and safe.
* You can be fully fluent within 5 minutes since it is just Python and a transparent library.
http://www.jperla.com/blog/post/weby-templates-are-easier-fa...
(That said, aside from Atom feeds I haven't had the need to output XML rather than JSON in a very long time)
It's not friendly to UI designers who like to load it into something like Dreamweaver or translate their static design into the template. I haven't thought of any good solution for that though. Zope TAL seemed like a valiant attempt but I'm sure how successful it was.
this way using a html mockup from a designer is like using an 3D from a 3D model artist, because you only load the data in, selecting what you want and putting a animatinon mesh / functionality into it.
tldr-part: look at my wip code → https://github.com/dodo/node-dynamictemplate/blob/a46fb6ed18...
html(
head(
title('This is the title')),
body(
div(id='header', body=...)))
We could also create a shortcut for div ID and classes.. for instance a keyword capitalized is an ID, or something starting with _ could be a class.It could then be possible to make "custom" fields:
html( headers(), left_side(), content(), footer())
E.html(
E.head(...),
E.body(...))OTOH I think I like your syntax better.
http://davidbau.com/downloads/templet.py
And some notes about the implementation:
http://davidbau.com/archives/2007/03/11/python_string_functi...