It might be nice to build the widget code through the pre-existing templating mechanism, along the lines of

```javascript
app.render('widget.js', { badges: badges }, function(err, code){
    if (err) 
      ...
    res.type('application/javascript');
    return res.send(code, 200);
});
```

This would be particularly nice if we'll be making changes to the HTML that the widget generates, which right now doesn't seem super flexible.