charlysisto had the right idea.
The answer was to use Sprockets & YUI Modules as the views / models.
//*=require_self
//*=require view/file_a.js
//*=require model/file_a.js
//*=require view/file_b.js
//*=require model/file_b.js
YUI().use('app','app-view-file-a','app-view-file-b','app-model-file-a','app-model-file-b', function(Y) {
Y.FileApp = Y.Base.create('fileApp', Y.App, [], {
views: {
fileA: {type: 'FileAView'},
fileB: {type: 'FileBView'}
}
}, {
ATTRS: {
root: {value: '/'}
}
});
var app = new Y.FileApp({
contentSelector: '#pjax-content',
serverRouting: true,
transitions: true,
container: '#file-app',
viewContainer: '#file-app-views'
}).render().showContent('#pjax-content', {view: 'FileAView'});
});
In the views & model files, you would just create them as you would for a normal YUI3 Module:
YUI.add('app-view-file-a', function(Y) {
Y.namespace('FileAView');
FileAView = Y.Base.create('fileAView', Y.View, [], {
template: Y.Handlebars.compile(Y.one('#file-a-template').getHTML())
});
Y.FileAView = FileAView;
},'0.1.0',{requires:['node','handlebars'], skinnable:false});
In the beginning, I actually got the File.read to work within the JS. But this method seemed very messy and didn't work very well in the development arena. Rails never knew to recompile the "parent" js file because the timestamp didn't change. If you are not using YUI, the File.read solution may work for you -- but I'd look for a different solution. Was pretty annoying have to enter a new line & delete every time I made a change to the child modules.