Techminded

ES7 JavaScript for Backbone

By recent moment Backbone was not really ready for modern ECMAScript (ES) standards as current ES6 haven't implemented class properties. It is described here in detail:

http://benmccormick.org/2015/04/07/es6-classes-and-backbone-js/

But a plugin was added recently to babel transpiler (es6-7 to old standard translator) that implements this feature so we can write the code in modern ways:

import Marionette from 'backbone.marionette';
import layoutTemplate from '../templates/index.hbs';
 
import Backbone from 'backbone';
 
 
export default class IndexView extends Marionette.LayoutView {
 
  template = layoutTemplate;
 
  constructor(...rest) {
    super(...rest);
 
  }
 
}

New syntax class properties was really missing thing for all this playings. The code will be traspilled to ES5 version compatible with all old browsers.

The full project template with support of Marionette and other related things can be found here:

https://github.com/syncro/es6-marionette

check it out than run:

npm install

and

gulp serve

Comments