In my app, I am using the handlebars template plugin, I am little bit confused here, how can i integrate handlebars template to marionette Item View which is using separate template?
here is my code :
define([
'jquery',
'underscore',
'backbone',
'marionette',
'hbs!scripts/templates/login/loginTemp'], // this is my handlebars template.
function ($,_,Backbone,Marionette,loginTemplate) {
"use strict";
socialApp = window.socialApp || {};
socialApp.loginView = Backbone.Marionette.ItemView.extend({
tagName:'div',
className:'loginContainer',
template: '#loginTemplate' //this is template for login alone (from DOM )
});
return socialApp.loginView;
}
);
"loginTemp" - has all details what i require for login template.
You could override
Marionette.TemplateCache.prototype.compileTemplate
function to achieve needed behavior:If you are using regions in your marionette application, such as
and if your template is written inside a script tag, then you can easily render your template in this manner:
and then,
My "Marionette-Handlebars Boilerplate" might help you:
https://github.com/yuraji/marionette-handlebars-boilerplate