The primary UI authoring technology in Ember.js is Handlebars. Handlebars templates allow HTML fragments to embed dynamic content using Handlebars expressions placed inside double curly braces ({{ }}
), the dynamic scripting blocks. Handlebars expressions perform data binding with attributes of routes, models, controllers, components, services, utils, and even application instances. Here is a sample Handlebars expression:
<h3>Welcome <strong>{{loggedInUser.fullName}}.</strong></h3>
This code snippet expects an object (preferably derived from Ember.Object
, though it binds with normal JS objects too) with the name loggedInUser
, present somewhere in the context in the parent context hierarchy (template, controller, route, or application). Then, it establishes a one-way data binding with the fullName
attribute of the loggedInUser
object; hence, it just displays the value of the bound attribute.