Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Last active August 29, 2015 14:18
Show Gist options
  • Save jamiebuilds/c30882eaa48420ac6955 to your computer and use it in GitHub Desktop.
Save jamiebuilds/c30882eaa48420ac6955 to your computer and use it in GitHub Desktop.
Babel Plugin Ideas

Babel Plugin Ideas

babel-plugin-backbone

import {View} from 'backbone';

export default class MyView extends View {
  initialize() {
    this.$el.css('color', 'red');
  }
}
import {View} from 'backbone';

const MyView = View.extend({
  constructor: function MyView() {
    View.apply(this, arguments);
  },

  initialize() {
    this.$el.css('color', 'red');
  }
});

export default MyView;

babel-plugin-ember

import {Controller, computed} from 'ember';

export default class MyController extends Controller {
  @computed('firstName', 'lastName')
  fullName() {
    return `${this.get('firstName')} ${this.get('lastName')}`;
  }
}
import {Controller, computed} from 'ember';

const MyController = Controller.extend({
  fullName: computed('firstName', 'lastName', function fullName() {
    return `${this.get('firstName')} ${this.get('lastName')}`;
  })
});

export default MyController;

babel-plugin-angular

export default class MyController {
  constructor($scope, $route) {
    this.$scope = $scope;
    this.$route = $route;
  }
}
export default class MyController {
  static $inject = ['$scope', '$route'];
  constructor($scope, $route) {
    this.$scope = $scope;
    this.$route = $route;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment