I am attempting to load pages and templates from models. The idea is that pages and templates would be created in a CMS and dynamically loaded by the application. Page and Template models are separate as multiple pages may use the same template.
For loading pages, I am doing something similar to what is done in the bitballs example app. I modified the pageComponentConfig to return a promise that resolves to the page rather than returning the page directly.
The pageComponent is also modified to return a promise. I had to move the pageComponent from being a stache helper to the AppViewModel as I don’t believe stache helpers support deferreds.
I then modified the index.stache to wait for the pageComponent to load.
{{#if pageComponent.isResolved}}
{{{pageComponent.value}}}
{{/if}}
I am having less success getting the templates to work with can.Component. Can can.Component be modified to accept a promise? Something like:
exports.Component = Component.extend({
tag: "player-list",
template: Template.findOne({ name: 'player-list'}),
viewModel: ViewModel
});
Or am I barking up the wrong tree? What would be the best way to accomplish this?