function (head, req) { var Mustache = require("vendor/couchapp/lib/mustache"); start({ "headers": { "Content-Type": "text/html" } }); var stash = {}; while (row = getRow()) { var affair = row.key; if (row.key == affair ) { var actions = []; actions.push(row.value[0]); stash.actions = actions; send(Mustache.to_html(this.templates.nextaction, stash)); } else { stash.affair = affair; actions = []; //stash.nextaction = action; send(Mustache.to_html(this.templates.nextaction, stash)); } } }