Created
August 22, 2011 18:22
-
-
Save mahemoff/1163092 to your computer and use it in GitHub Desktop.
Kaffeine+Ugly in Express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kaffeine = new (require("kaffeine"))(); | |
app.register('.k', { | |
compile: function(str, options) { | |
return function(locals) { return uglify(kaffeine.compile(str)) }; | |
} | |
}); | |
function uglify(js) { | |
var jsp = require("uglify-js").parser; | |
var pro = require("uglify-js").uglify; | |
var orig_code = "... JS code here"; | |
var ast = jsp.parse(js); | |
ast = pro.ast_mangle(ast); | |
ast = pro.ast_squeeze(ast); | |
return pro.gen_code(ast); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment