Ho questo errore, ma il diverso tra this question e la mia domanda è che sto usando gulp invece grugnito.Il modello è stato precompilato con una versione precedente di Handlebars rispetto al runtime corrente
In primo luogo, il runtime del manubrio è manubri v4.0.5 (file js).
L'uscita del manubrio -v è 4.0.5
Questo è il mio gulpfile.js:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var concat = require('gulp-concat');
gulp.task('default', ['templates','scripts'], function() {
});
gulp.task('templates', function() {
gulp.src('templates/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'MyApp.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest('js/dist'));
});
gulp.task('scripts', function() {
return gulp.src([
'bower_components/handlebars/handlebars.runtime.js',
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/dist/bootstrap.js',
'js/dist/templates.js',
'js/main.js'])
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('js/dist/'));
});
main.js
"use strict";
var data = { title: 'This Form', name: 'Joey' };
var html = MyApp.templates.hellotemplate(data);
// console.log(html);
$(document).ready(function() {
$('#dynamic-content').html(html);
});
Dove può essere il mio problema?
Errore:
Uncaught Error: Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version (>= 4.0.0) or downgrade your runtime to an older version (>= 2.0.0-beta.1).
ho precompilati i modelli che utilizzano sorso comando.
Grazie mille !!
Io suggerisco di usare risposta @Griffin, perché se si desidera eseguire 'npm update' in questo caso la dipendenza sarebbe probabilmente cambiare. – jzasnake