Reputation: 13430
Using Backbone.View I used to get external template in this way (1)
What if I would like to get the template from external file using Backbone.Marionette.Layout? (2)
(1)
define(['myTemplate.html'], function (myTemplate) {
var MyView = Backbone.View.extend({
render: function ()
{
this.$el.html(myTemplate, this.getView());
}
});
return MyView;
});
(2)
define(['myTemplate.html'], function (myTemplate) {
var Layout = Backbone.Marionette.Layout.extend({
template: "#container",
regions: {
top: "#top",
main: "#main"
}
});
return Layout;
});
Upvotes: 4
Views: 2813
Reputation: 18863
Take a look at this: https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs
this.$el.html(myTemplate, this.getView());
Upvotes: 2