YUI3 Bootstrapper for Node.js
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitmodules
LICENSE
README.textile
package.json
test.js

README.textile

YUI Bootstrapper for Node.js

This node.js module attempts to setup and bootstrap a working YUI 3 instance.
It does not support any DOM manipulation, but it gives you our class management
and language extras.

I am working on an IO replacement to use the internal node.js methods instead of XMLHttpRequest

Setup this repo

I am using a submodule of the official YUI 3 repository, so you need to issue this after you pull this fork:

    git submodule init
    git submodule update

That should pull in the latest build of the /yui/yui3 repo.

Including the files

    // get the exported YUI object
    var YUI = require('./lib/node-yui3')).YUI;

Using YUI

// load YUI
var YUI = require("./lib/node-yui3").YUI;

//sys.puts('After: ' + sys.inspect(process.memoryUsage()));

//Now use non-DOM related YUI utilities
YUI({
    filter: 'debug',
    debug: true
}).use('io-base', 'json', 'base', function(Y) {

    //sys.puts('Inside: ' + sys.inspect(process.memoryUsage()));
    //Logger outputs with sys.puts
    Y.log('This is a test');
    //Lang is available
    Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp');

    //Creating a simple class
    var One = function() {
        One.superclass.constructor.apply(this, arguments);
    };
    //Extending it with Y.Base so we have Custom Events and a lifecycle
    Y.extend(One, Y.Base, {
        test: function() {
            this.publish('foo', {
                emitFacade: true
            });
            this.fire('foo');
        }
    }, {
        NAME: 'one'
    });

    //Create a new instance of our new class
    var o = new One();
    o.on('foo', function(o) {
        Y.log('Foo Fired', 'debug', 'myapp');
        //Y.log(o, 'debug');
    });
    o.test(); //Should fire the one:foo Event.
});

Now you can run node ./test.js