Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions shared/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ if (!isServer) {
module.exports = Backbone.Model.extend({

defaults: {
loading: false,
templateAdapter: 'rendr-handlebars'
loading: false
},

/**
Expand Down Expand Up @@ -49,9 +48,12 @@ module.exports = Backbone.Model.extend({
*
* We can't use `this.get('templateAdapter')` here because `Backbone.Model`'s
* constructor has not yet been called.
*
* In order to support more packagers, instead of setting `templateAdapter`,
* you should override the `getTemplateAdapterModule` method.
*/
var templateAdapterModule = attributes.templateAdapter || this.defaults.templateAdapter;
this.templateAdapter = require(templateAdapterModule)({entryPath: entryPath});
var templateAdapterModule = this.getTemplateAdapterModule(attributes.templateAdapter)
this.templateAdapter = templateAdapterModule({entryPath: entryPath});

/**
* Instantiate the `Fetcher`, which is used on client and server.
Expand Down Expand Up @@ -94,6 +96,17 @@ module.exports = Backbone.Model.extend({
return require('../client/app_view');
},

/**
* @shared
*/
getTemplateAdapterModule: function(moduleName) {
if (!moduleName || moduleName === 'rendr-handlebars') {
return require('rendr-handlebars');
} else {
return require(moduleName);
}
},

/**
* @client
*/
Expand Down