« All deprecation guides
Deprecation Guide for Ember.String.fmt
until: 3.0.0
id: ember-string-fmt
Ember.String.fmt
was designed at a time when interpolating values in a JavaScript
string was cumbersome. With template strings, it has become pratical to do it, and
they are recommended over Ember.String.fmt
.
To use the examples from the documentation, you should update your code from:
let firstName = 'John';
let lastName = 'Doe';
"Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe"
"Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John"
To the following:
let firstName = 'John';
let lastName = 'Doe';
`Hello ${firstName} ${lastName}` // "Hello John Doe"
`Hello ${lastName}, ${firstName}` // "Hello Doe, John"