jeudi 4 janvier 2018

Updating from Ember 1.8.1 to Ember 1.9 with Ember Starter Kit

I'm am currently updating an Ember app built with Ember Starter kit from Ember 1.8.1 to 1.9 and Handlebars 2.0. I’m trying to update successfully without having to refactor a lot of code - I’m hoping this is possible.

At the moment, I’m getting an error in the console which says ‘Error: Unknown template object: function’. From what I have read it is because I’m using a template compiler which only understands Handlebars 1.3. I’m currently using Gulp to compile my templates. I’ve moved from gulp-ember-templates to gulp-handlebars which states that I can compile my templates using a specific Handlebars version.

This is how my 'templates' gulp task looks like:

gulp.task('templates', function () {
    gulp.src(paths.dev.templates + '**/*.hbs')
    .pipe(handlebars({
        handlebars: require('handlebars')
    }))
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(declare({
        namespace: 'TM.TEMPLATES',
        noRedeclare: true,
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('public/app'))
});

..and my package.json has

  "devDependencies": {
    "handlebars": "^2.0.0"
  }

I've read that I may need to update the runtime version, but I don't know where I can do this so I assumed if I installed the latest ember-template-compiler from NPM and referenced it in my gulpfile like below

//COMPILE ALL PULGIN FILES
gulp.task("all", function(){
    return gulp.src([
            paths.dev.vendor + "jquery/dist/jquery.js",
            paths.dev.vendor + "handlebars/handlebars.js",
            "/node_modules/ember-template-compiler/lib/main.js",
            paths.dev.vendor + "ember/ember.js", 
        ])
        .pipe(concat("all.js"))
        .pipe(gulp.dest("public/js/"));  
});

...it would work.

Unfortunately, I'm still getting ‘Error: Unknown template object: function’. I understand I could try and migrate the app over to Ember CLI there is no capacity for this at the moment.

Thanks.




Aucun commentaire:

Enregistrer un commentaire