TypeError: Handlebars.template is not a function Handlebars 3.0.3
Closed this issue · 0 comments
dylanrhysscott commented
Hi,
I'm having an issue with gulp-handlebars returning TypeError: Handlebars.template is not a function. It has been working relatively flawless up until now however it appears to have stopped. Any ideas what I'm missing here?
Looking in the bower folder handlebars is showing as 3.0.3 same as with the node modules folder. Looking at the resulting compiled templates file however all templates appear to be showing "compiler":[6,">= 2.0.0-beta.1"]
which I suspect maybe the cause
console.log Handlebars in the browser returns handlebars but the template property is an empty object
My package.json
"devDependencies": {
"handlebars": "^3.0.3",
"gulp": "^3.8.11",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.5.2",
"gulp-declare": "^0.3.0",
"gulp-handlebars": "^4.0.0",
"gulp-jshint": "^1.9.2",
"gulp-rename": "^1.2.0",
"gulp-sequence": "^0.3.2",
"gulp-uglify": "^1.1.0",
"gulp-watch": "^4.1.1",
"gulp-wrap": "^0.11.0",
"gulp-yuidoc": "^0.1.2"
}
My bower.json
"dependencies": {
"bootstrap": "~3.3.2",
"jquery": "~2.1.3",
"sammy": "~0.7.6",
"showdown": "~0.4.0",
"handlebars": "3.0.3",
"pagedown": "~1.1.0"
},
"devDependencies": {
"jqueryui": "~1.11.4"
}
My gulp tasks
gulp.task('templates', function() {
gulp.src(['public/templates/**/*.hbs', 'public/templates/*.hbs'])
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'Handlebars.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest('public/js/'));
});
gulp.task('watch', function() {
gulp.watch(['public/templates/*.hbs', 'public/templates/**/*.hbs'], ['templates']);
gulp.watch(['public/js/*.js', 'public/js/**/*.js'], ['build']);
});
Thanks