Chapter 4. Automatically updating templates with Handlebars.js

 

This chapter covers

  • Understanding why you need templates
  • Working with Handlebars.js expressions
  • Using simple and complex expressions
  • Understanding the relationship between Ember.js and Handlebars.js
  • Creating your own custom expressions

Ember.js doesn’t include a default template library, and you’re free to use your favorite JavaScript library. But because the same people who are behind Ember.js are also behind Handlebars.js, Handlebars.js is an especially nice fit for Ember.js applications. Handlebars.js also has all the features that you’re looking for in a solid template library. Handlebars.js is based on Mustache, which is a logic-less template library that exists for many programming languages, including JavaScript, Python, Java, Ruby, and most likely your favorite language.

In this chapter, you’ll start by getting a clear understanding of what a template is and why you should be excited about using one, before moving on to the features that Handlebars.js provides. In the second half of the chapter, you’ll look at how Ember.js extends the standard Handlebars.js features to provide automatically updated templates for your application. This chapter should leave you with a comprehensive understanding of the template features that are built into Handlebars.js and Ember.js.

4.1. What’s in a template?

4.2. Built-in block expressions

4.3. Using Handlebars.js with Ember.js

4.4. Ember.js-provided Handlebars.js expressions

4.5. Creating your own expressions

4.6. Summary

sitemap