If you don't mind, I can make a few suggestions about your coding practice for SilkJS?
You can do:
include.path.push('rpc');
Then you can:
global.Addresses = require('Addresses.sjs')
You can include.path.push('apps/clubs/tempaltes/assets/cms_api'), too
You generally don't use .extensions on names in require.
So require('foo.js') works, but isn't best practice. You'd want to do require('foo') - require() will do the right thing.
The .sjs extension is intended for server-side JavaScript code, which SilkJS handles specially. It is meant to be used like .php scripts with Apache. That is, the server sees /index.sjs, finds index.sjs in your document root, and executes it.
The require() functionality is really neat. You can require() a directory as well as a file. The directory must have an index.js file inside, which is actually loaded. For example:
cms/
cms/index.js:
exports.extend({
CMS_main: require('lib/main'),
CMS_extras: require('lib/extras'),
… // etc.
});
cms/lib
cms/lib/main.js:
exports = function() {
// whatever your CMS_main() does
};
cms/lib/extras.js
exports = function() {
// whatever your CMS_extras() does
};
Then in your code, you can:
var main = require('CMS').CMS_main,
extras = require('CMS').CMS_extras;
See?
Your use of global namespace is fine, but some people will find you're "polluting" the global namespace.
One of the beautiful things about require() is that you can use it many many times on the same module. The first time, it compiles the module and returns its exports variable/object. The second, third, etc., time, it just returns the exports variable/object again - no compilation is done the 2nd, 3rd, etc. times.
So, in your .jst files, you can:
<%
var CMS = require('CMS');
// use CMS
%>
You can require('CMS") in all of your .jst with a teeny tiny performance penalty (the time to lookup the filename 'CMS' in a hash and return its exports object . So small I wouldn't worry about it (code correctness and readability is better).
This scheme lets you "pollute" just your .jst program's space, without messing with global.
Call it the force. Use the force, luke!
Otherwise, your code has a very nice style to it.