Pythonic, XML-based Templating
Standard XHTML makes the templates easy-to-use for designers. The programming syntax is a no-brainer for Python programmers. Also includes an easy XSLT-like "match" command. Produces syntactically correct output.
Your designer will love you for using Kid. As far as they're concerned, they're just giving you XHTML that you put some extra stuff into. The designs they put together can even have sample data that hangs around and gets replaced by the real data when the time comes.
OK, sure. Not everyone works with a designer. (I've seen lots of pages that prove that. I've made lots of pages that prove that!) That's OK... Kid is friendly for programmers, too.
If you were generating your output in straight Python, you could do something like this:
In a Kid template, you just do it like this:
The expressions in Kid's "for" and "if" commands are standard Python! Note also that the example above is the "designer-friendly" form that would have nice sample data to show in an editor or browser. If you want, you can use the more succinct "$${person.name}" instead of having the extra <span>.
Sure, we all use CSS these days to apply consistent style throughout our apps, but you still need a mechanism for consistent headers and footers. Kid provides a couple of useful ways to do this.
You can create a header in a "template function" in a master template that looks something like this:
Then, your individual templates will "extend" your master template and call the function to insert the header:
Kid has a great feature that gives you some of XSLT's power without XSLT's syntax: the "match" command. As in the previous example, you'd have your template extend a master template. However, rather than explicitly calling a header function, the master template will add the header through matching.