Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Derby.js: split client-side only code into several files

Derby.js: split client-side only code into several files

Problem

I'm trying to split some client-side-only Code into several files in a Derby.js project. It has to be client-side only since it's interacting with the TinyMCE editor. So I tried:

app.ready(function(model) {
    var tiny = derby.use(require('../../lib/app/TinyMCE'))
    //other client-side code
}

and put the following into lib/app/TinyMCE.js:

var derby = require('derby')
module.exports.decorate = 'derby'; //because before I got an 'decorate' is undefined error...
module.exports.TinyMCE = function() {
    //code
}

But now I'm getting a object is not a function error.

Am I even on the right track? I also considered putting the code in the public directory, but the cache-expiration of one year makes this rather inconvenient.

Also, is there really no isServer or isClient method to query?

Problem courtesy of: mb21

Solution

Okay, I don't know whether that's a good way, but I got it working:

module.exports = tiny
tiny.decorate = 'derby'
function tiny() {
     //code
}
Solution courtesy of: mb21

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Derby.js: split client-side only code into several files

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×