home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
1.13
  • Packages
    • ember
    • ember-application
    • ember-debug
    • ember-extension-support
    • ember-htmlbars
    • ember-metal
    • ember-routing
    • ember-routing-htmlbars
    • ember-routing-views
    • ember-runtime
    • ember-templates
    • ember-testing
    • ember-views
  • Namespaces
    • Ember
    • Ember.FEATURES
    • Ember.String
    • Ember.computed
    • Ember.inject
    • Ember.run
  • Classes
    • Ember.Application
    • Ember.Array
    • Ember.ArrayProxy
    • Ember.Binding
    • Ember.Checkbox
    • Ember.Component
    • Ember.ComputedProperty
    • Ember.ContainerDebugAdapter
    • Ember.Controller
    • Ember.ControllerMixin
    • Ember.CoreObject
    • Ember.DataAdapter
    • Ember.DefaultResolver
    • Ember.Error
    • Ember.Evented
    • Ember.Helper
    • Ember.InstrumentationSupport
    • Ember.Logger
    • Ember.Mixin
    • Ember.MutableArray
    • Ember.MutableEnumerable
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Object
    • Ember.Observable
    • Ember.PromiseProxyMixin
    • Ember.Route
    • Ember.Router
    • Ember.Service
    • Ember.Test
    • Ember.Test.Adapter
    • Ember.Test.QUnitAdapter
    • Ember.TextArea
    • Ember.TextField
    • Ember.VisibilitySupport
    • RSVP.EventTarget
    • RSVP.Promise

Package ember-templates public


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:

// app/components/person.js
export default Ember.Component.extend({
  name: 'Jill'
});
{{! app/components/person.hbs }}
{{name}}
<div>{{name}}</div>
<span data-name={{name}}></span>

Any time the "name" property on the component changes, the DOM will be updated.

Properties can be chained as well:

{{aUserModel.name}}
<div>{{listOfUsers.firstObject.name}}</div>

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:

{{if name "I have a name" "I have no name"}}
<span data-has-name={{if name true}}></span>

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:

{{#if name}}
  I have a name
{{else}}
  I have no name
{{/if}}

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:

<span data-name={{concat firstName (
 if lastName (concat " " lastName) "Doe"
)}}></span>

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.

Classes

  • Ember.Helper
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.