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

Ember Views

Ember Views

For the NYC SC/Ember meetup.

Raymond Cohen

June 11, 2012
Tweet

Other Decks in Programming

Transcript

  1. Basics • A template is a function that builds a

    string • Handlebars compiles strings to templates • templateName is a key into Ember.TEMPLATES
  2. Helpers • Functions invoked by {{fn-name params}} • Invoked during

    view render • Output a string to the buffer • Can set up property observers
  3. How {{#if}} works • Create metamorph view • Observe App.loggedIn

    • On change, switch template Blocks become templates
  4. Ember.ContainerView • Templates can’t always describe all UI • Sometimes

    more flexibility is required • ContainerView holds other view instances, allows code to add, remove, reorder • set currentView property • or manage childViews array
  5. Result • Controller is context for a chunk of DOM

    • Controller is good place to have properties that many views access • Reduces need to bind lots of values to the views themselves • Moving things around in templates is easier
  6. Creating helpers • Main issue is having bindings work within

    your helper’s output • Easiest path: call one of the other helpers from your helper after some setup • Future: easier ability to bind some types of helpers (see PR 615)
  7. Resources • emberjs.com/guides/ • emberist.com/ - Peter Wagenet’s blog •

    IRC - #emberjs on Freenode • bring your jsfiddle!