You are also able to create a full Javascript class for a view.

Create a new file called myapp/views/main-views.js.

new JsView('HelloView', function (params, context, inner) {
    return function(cb) {
        cb('Hello from JsView!');  
    };
});

Now change your controller at controllers/main-controllers.js to the following:

new Controller("hello", {
    "execute": function(params, context) {
         return function(cb) {
             context.view_name = "HelloView";
             cb();
         };
    }
});

And launch the application with

$ node run_console.js hello

it will output now

Hello from JsView!

Comments