Our combo-handler supports hooks, so when the YUI Loader makes a request like:
/combo/_/handlebars/GW2/items.handlebars
the handlebars hook fires, splits up the request on "/" characters then does a bit of a dance to determine what namespaced object the Template.js file should create.
...
groups : {
views : {
"view-home-sidebar" : {
path : "view-home-sidebar.js",
requires : [
"base",
"view",
"gw2-template-home-sidebar",
"gw2-template-home-sidebar-item"
]
}
},
"gemstore-templates" : {
combine : true,
comboBase : "/combo/_",
root : "/handlebars/GW2/",
patterns : {
"gw2-template" : {
configFn : function(me) {
me.path = me.name.replace("gw2-template-", "") + ".handlebars";
me.requires = [ "handlebars-base" ];
}
}
}
}
}
...
YUI.add('gw2-template-items', function(Y) {
Y.namespace('GW2.Templates')['items'] = Y.Handlebars.template(
//generated handlebars FN
);
}, '', { requires : [ 'handlebars-base' ]});
var Templates = Y.namespace("GW2.Templates");
Views.Base = Y.Base.create("viewBase", Y.View, [], {
template : Templates.items,
initializer : function(config) {
var self = this;
Y.Handlebars.registerPartial("item", Templates.item);
},
render : function() {
this.get("container").setContent(this.template({}));
}
});
Left as an exercise for the reader, as that part is for our custom server-side app framework.