require-handlebars-plugin
require-handlebars-plugin copied to clipboard
Not precompiling templates?
In development, everything works just fine but when I move to production, my templates are just plain text, causing them to not render.
In production, after running a successful node r.js -o app.build.js, I notice that the network traffic is correct (only seeing main.js), but when I console.log my templates in my view, it's just a string of the template's HTML, but the compiled function that I would expect.
({
appDir:".",
baseUrl:"./client",
dir:"./build",
optimizeCss:"standard",
inlineText:!0,
pragmasOnSave: {
excludeHbsParser:!0,
excludeHbs:!0,
excludeAfterBuild:!0
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
handlebars: {
exports: 'Handlebars'
},
marionette: {
deps: ['backbone'],
exports: 'Marionette'
},
"marionette.handlebars": {
deps: ['backbone', 'marionette'],
exports: "Marionette.Handlebars"
}
},
paths: {
jquery: "lib/jquery-1.10.2.min",
hbs: "lib/hbs",
json2: "lib/json2",
i18nprecompile: "lib/i18nprecompile",
marionette: "lib/backbone.marionette",
"marionette.handlebars": "lib/marionette.handlebars",
underscore: "lib/underscore-min",
backbone: "lib/backbone-min",
handlebars: "lib/handlebars"
},
locale:"en_ca",
hbs:{
templateExtension:"hbs",
disableI18n:!1
},
modules:[
{
name: "main"
}
]
})
example view:
define([
'jquery',
'underscore',
'backbone',
'handlebars',
'marionette',
'marionette.handlebars',
'hbs!templates/item/item',
'hbs!templates/item/backpack'
],
function($, _, Backbone, Handlebars, Marionette, MarionetteHandlebars, itemTemplate, backpackTemplate) {
var ItemView = Backbone.Marionette.ItemView.extend({
template: itemTemplate,
onRender: function() {
console.log(this.template)
}
});
var BackpackView = Backbone.Marionette.CollectionView.extend({
itemView: ItemView,
template: backpackTemplate
});
return {
ItemView: ItemView,
BackpackView: BackpackView
};
});