ember-templates Module
Parent: ember
Ember templates are executed by HTMLBars, an HTML-friendly version of Handlebars. Any valid Handlebars syntax is valid in an Ember template.
Showing a property
Templates manage the flow of an application's UI, and display state (through the DOM) to a user. For example, given a component with the property "name", that component's template can use the name in several ways:
1 2 3 4 |
// app/components/person.js export default Ember.Component.extend({ name: 'Jill' }); |
Any time the "name" property on the component changes, the DOM will be updated.
Properties can be chained as well:
Using Ember helpers
When content is passed in mustaches {{}}
, Ember will first try to find a helper
or component with that name. For example, the if
helper:
The returned value is placed where the {{}}
is called. The above style is
called "inline". A second style of helper usage is called "block". For example:
The block form of helpers allows you to control how the UI is created based on the values of properties.
A third form of helper is called "nested". For example here the concat helper will add " Doe" to a displayed name if the person has no last name:
Ember's built-in helpers are described under the Ember.Templates.helpers namespace. Documentation on creating custom helpers can be found under Ember.Helper.
Invoking a Component
Ember components represent state to the UI of an application. Further reading on components can be found under Ember.Component.