Template Helpers and Computed Properties

EmberCamp London 2016: I Can Write My App with No Handlebars by Lauren Tan

  • Think of template helpers as computed property macros
  • Rule of least power
  • Keywords: action, component, concat, debugger, each, each-in, get, hash, if, input, link-to, loc, log, mut, outlet, partial, query-params, render, textarea, unbound, unless, with.
  • What makes a good helper?
    • Purity – be careful with objects and arrays
    • Think about your interface (ember-changeset)
      • Returning basic types is simple
      • Gotta be careful with objects and arrays
      • Higher-order functions (ember-composable-helpers)
      • Class-based helpers
        • Don’t use observers anywhere but here
    • Computed vs helper
      • Computed is for business logic (domain specific)
      • Helpers are best-suited for generic utilities

EmberCamp London 2016: Crafting the Perfect Computed Property by Serena Fritsch

  • Computed property macros: alias, and, bool, collect, deprecatingAlias, empty, equal, filter, filterBy, gt, gte, intersect, lt, lte, map, mapBy, match, max, min, none, not, notEmpty, oneWay, or, readOnly, reads, setDiff, sort, sum, union, uniq, uniqBy
  • What’s interesting about this is that they wrote their own very dumb parser. I kind of see Ember as a very powerful DSL that you can extend. In this case they extended it by making the DSL richer.
  • https://www.youtube.com/watch?v=Tar4WgAfMr4