Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use sugar.js in nodejs?

http://sugarjs.com/

It's a libary so I can load it in browser directly. It's also a npm package, but how can I use it as a moudule?

In browser, load a js file will change the objects easily, but is not the same while working in nodejs, and I can't figure it out.

like image 222
jiyinyiyong Avatar asked Feb 17 '12 01:02

jiyinyiyong


1 Answers

You just install the module:

npm install sugar

then use it just like the API says:

var http = require('http');
var sugar = require('sugar');

http.createServer(function (req, res) {

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('hey_there_good-lookin'.camelize());

}).listen(process.env.PORT || 8080);
like image 102
Justin Beckwith Avatar answered Sep 17 '22 14:09

Justin Beckwith