jeudi 22 janvier 2015

Pre-compiled handlebars templates error

I'm trying to pre-compile my handlebars templates. I've implemented this(Github) plugin for pre-compilation in Grunt and it seemed to work just fine. But when I opened up the Ember application the console had the following error:



Uncaught Error: Unknown template object: function handlebars-v2.0.0.js:455
template handlebars-v2.0.0.js:455
hb.template handlebars-v2.0.0.js:644
(anonymous function) Templates.js:1


After that, I tried this(Github) command line solution which gave precisely the same error.


I've done some research and most sources say that there is a version mismatch. I've checked everything and both compilers run on handlebars.js version 2.0.0. I'm kind of running out of ideas.


Gruntfile:



module.exports = function(grunt) {
grunt.initConfig({
emberhandlebars: {
compile: {
options: {
templateName: function(sourceFile){
return sourceFile.replace('Views/Handlebars/', '').replace('.hbs', '');
}
},
files: [
'Views/Handlebars/*.hbs'
],
dest: 'JS/templates.js'
}
}
})

//Load the Ember template compiler
grunt.loadNpmTasks('grunt-ember-template-compiler');

//Register default grunt task
grunt.registerTask('default', ['emberhandlebars']);
}


Command I used for the command line compiler:



ember-precompile Views/Handlebars/*.hbs -f JS/Templates.js


I hope someone has any idea what I'm doing wrong here.





Aucun commentaire:

Enregistrer un commentaire