EmberScript

Ember.js-infused CoffeeScript

Gordon L. Hempton / @ghempton / emberscript.com

OMG EmberScript? You are on drugs.

What is Ember.js?

Ember diagram
Ember diagram with highlights

Motivation

  • Tedious
    • Getters/setters
    • Computed property dependencies
  • CoffeeScript impedance mismatch
    • Classes
    • Indentation

Language Support For

  • Getters and setters
  • Classes and mixins
  • Computed properties and observers

Object Model

class Animal

mixin CanFly
  fly: -> console.log('flying')

class Bird extends Animal with CanFly

  fly: ->
    super()
    console.log('flap wings')

					

Accessors

person.firstName

person.firstName = "Wes"

@person.firstName = "Andrew"

person*.firstName

					

Computed Properties & Observers

class App.PostsController extends Ember.ArrayController

  +computed content.length
  headerDisplay: ->
    "#{@content.length} Posts"

  +observer content.length
  contentChanged: ->
    console.log "@content changed"

					

Dependency Inference

class App.PostsController extends Ember.ArrayController

  headerDisplay: ~>
    "#{@content.length} Posts"

					

Getting Started

  • gem 'ember_script-rails'
  • application_controller.em

Haml : CoffeeScript :: Emblem : EmberScript

emblemjs.com

Thanks CoffeeScriptRedux

by Michael Ficarra

EmberScript

Ember.js infused CoffeeScript

Gordon L. Hempton / @ghempton / emberscript.com