Dominate HTML in Python #

Have you ever wished that you had a sweet little API to generate HTML in Python? Dominate is probably what you are looking for.

Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API.

Now, I’m a self admitted HTML purist, but look at how the dominate API works.

from dominate.tags import ul, li
list = ul()
for item in range(4):
    list += li('Item #', item)

If done correctly HTML generators can blend in with your code nicely.

Checkout Dominate the next time you’re looking for a nice native HTML generator API for python.

hogan.js: Mustache compiler from Twitter #

Hogan is a console compiler for Mustache templates, complete with a fantastic name and man page.
Aiming not only for speed, Hogan boasts a parser API:

var text = "{{^check}}{{i18n}}No{{/i18n}}{{/check}}";
text +=  "{{#check}}{{i18n}}Yes{{/i18n}}{{/check}}";
var tree = Hogan.parse(Hogan.scan(text));

// outputs "# check"
console.log(tree[0].tag + " " + tree[0].name);

// outputs "Yes"

Just released on the hub, check the web site for usage.

nodestream: Templating for realtime apps in Node.js #

Technologies like Websockets lead us to rethink how we construct our web applications. Model-View-Controller (MVC)-based frameworks have encouraged us to chunk up markup into templates that are served up in response to controller actions. Different approaches for updating application views are emerging as browser clients take on more and more responsibilities.

For Node.js applications, LearnBoost has released Nodestream which adds realtime template updating to your application. Take the following Express application snippet and Jade template:

// app.js
app.get('/', function(req, res){
        res.render('items.jade', {locals: { items: items }})
})'/save/item', function(req, res){
    database.saveItem(req.body, function(){

// items.jade
- each item in items
        p This is an item titled #{item.title}

Nodestream allows your templates to get updated in realtime with using Websockets and JavaScript with only a couple of changes.


First we need to notify Nodestream of an update, emitting a newitem event when we save an item to the database:

    nodestream.emit('newitem', item)

… and then hook into that even in our template:

:realtime(append: 'newitem', local: 'items', obj: 'item')
        p This is an item titled #{item.title}

Now our views are updated after new items are add, even in multiple tabs! Awesome.

Be sure and check the README for full installation instructions and other usage guidelines.

[Source on GitHub]

handlebars.js: Optimized JavaScript templating based on Mustache.js #

If you’ve ever used Jan Lehnardt’s Mustache.js, a port of Chris Wanstrath’s logic-less views project Mustache, be sure and checkout Handlebars.js from Yehuda Katz. Handlebars builds on Mustaches’ namesake {{mustaches}} data binding syntax by adding support for path-based expressions, block helpers, and optimized partial support.


Binding deep hashes with Mustache can be cumbersome. Yehuda’s new path-based expressions let you specify XPath-style expressions to bind to values deep within a nested data structure. Given the following data:

var data = {"person": { "name": "Alan" }, company: {"name": "Rad, Inc." } };

you could bind to company name with an expression like:


[Source on GitHub] [Yehuda’s blog ppst]