node.js - using weld with express? node.js - using weld with express? express express

node.js - using weld with express?


I think something like this would work. Haven't tested though.

var fs = require('fs'),     jsdom = require('jsdom'),    app = require('express').createServer();app.get('/', function(req, res) {    jsdom.env('./test.html', ['./jquery.js', './weld.js'], function(errors, window) {        var data = [{            name : 'hij1nx',            title : 'code slayer'        }, {            name : 'tmpvar',            title : 'code pimp'        }];        window.weld(window.$('.contact')[0], data);        res.send(window.document.innerHTML); //after the welding part we just send the innerHTML        window.close();  // to prevent memory leaks of JSDOM    });});app.listen(3001);