home
  • Blog
2.12
  • Getting Started
  • Tutorial
  • The Object Model
  • Routing
  • Templates
    • Handlebars Basics
    • Built-in Helpers
    • Conditionals
    • Displaying a List of Items
    • Displaying the Keys in an Object
    • Binding Element Attributes
    • Links
    • Actions
    • Input Helpers
    • Development Helpers
    • Writing Helpers
  • Components
  • Controllers
  • Models
  • Application Concerns
  • Testing
  • Ember Inspector
  • Addons and Dependencies
  • Configuring Ember.js
  • Contributing to Ember.js
  • Glossary
Old Guides - You are viewing the guides for Ember v2.12.0.
Go to v5.0.0

Built-in Helpers

Edit pencil

Built-in Helpers

In the last section you learned how to write a helper. A helper is usually a simple function that can be used in any template. Ember comes with a few helpers that can make developing your templates a bit easier. These helpers can allow you to be more dynamic in passing data to another helper or component.

Using a helper to get a property dynamically

The {{get}} helper makes it easy to dynamically send the value of a variable to another helper or component. This can be useful if you want to output one of several values based on the result of a computed property.

{{get address part}}

if the part computed property returns "zip", this will display the result of this.get('address.zip'). If it returns "city", you get this.get('address.city').

Nesting built-in helpers

In the last section it was discussed that helpers can be nested. This can be combined with these sorts of dynamic helpers. For example, the {{concat}} helper makes it easy to dynamically send a number of parameters to a component or helper as a single parameter in the format of a concatenated string.

{{get "foo" (concat "item" index)}}

This will display the result of this.get('foo.item1') when index is 1, and this.get('foo.item2') when index is 2, etc.

left arrow
Handlebars Basics
Conditionals
right arrow
On this page

  • Built-in Helpers
  • Using a helper to get a property dynamically
  • Nesting built-in helpers
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 2023 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue