Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember.js: Hipster Hamster Framework

Ember.js: Hipster Hamster Framework

High level introduction to Ember focusing less on code and more on what it's all about

Avatar for Billy Shih

Billy Shih

June 12, 2013
Tweet

More Decks by Billy Shih

Other Decks in Programming

Transcript

  1. Bindings -Keep 2 objects in sync -Country will update its

    president name whenever you change president
  2. Computed Properties Auto-updating Templates -Create functions that can be used

    as properties -Templates are bindings aware so they update when you data changes
  3. Interactive (MVC Framework) Static (No JavaScript) -When to use Ember?

    -Spectrum: Static sites don’t need JS, interactive sites do -Can get away with just JQuery but JQuery relies on the HTML -Changing the HTML can break functionality unless you track of changes in the HTML done by JQuery necessary = lots of work
  4. Interactive (MVC Framework) Static (No JavaScript) JQuery -When to use

    Ember? -Spectrum: Static sites don’t need JS, interactive sites do -Can get away with just JQuery but JQuery relies on the HTML -Changing the HTML can break functionality unless you track of changes in the HTML done by JQuery necessary = lots of work
  5. -Popular alternatives -Angular is most popular to compare against right

    now -Ember provides more than these frameworks do, but as always, use the right tool for the right job
  6. “A framework for creating ambitious web applications.” -Ambitious is the

    key word -Goal is to compete with native apps and so borrows heavily from developing native applications, especially from Cocoa
  7. Router this.resource('tables') App.TablesRoute Controller App.TablesController Model App.Table View App.TablesView Template

    tables Tables Resource -5 core pieces of Ember -Naming convention is CRITICAL -Since Ember does a lot for you, if you don’t name things correctly, it won’t work
  8. Views Controllers ORM Data Store Rails JS Ember ERB HTML

    ActionController ActiveRecord mySQL/ Postgres $.html $.live $.ajax Resful API Handlebars Ember.js Ember Data Resful API https://speakerdeck.com/ardell/ember-dot-js-rails -Rails MVC is NOT Ember MVC -JS works but harder to ensure data and views match -Ember takes over to help with that
  9. - Ember uses and builds upon Handlebars.js - Extension of

    the Mustache templating language - Helps keep logic from the view
  10. <script id="entry-template" type="text/x-handlebars-template"> <div class="entry"> <h1>{{title}}</h1> <div class="body"> {{body}} </div>

    </div> </script> var source = $("#entry-template").html(); var template = Handlebars.compile(source); var context = {title: "My New Post", body: "This is my first post!"} var html = template(context); <div class="entry"> <h1>My New Post</h1> <div class="body"> This is my first post! </div> </div> -Regular HTML with handlebars expression {{ content }} -Add template through script tags -Compile a template in JavaScript with Handlebars.compile -Get HTML by executing the template with a context
  11. Ember.js http://emberjs.com Handlebars.js http://handlebarsjs.com Peepcode https://peepcode.com/products/emberjs TodoMVC http://todomvc.com/architecture-examples/ emberjs/#/ Jason

    Ardell https://speakerdeck.com/ardell/ember-dot- js-rails Robin Ward http://eviltrout.com/2013/02/10/why- discourse-uses-emberjs.html Sources