home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
2.18
  • Packages
    • @ember/application
    • @ember/array
    • @ember/component
    • @ember/controller
    • @ember/debug
    • @ember/engine
    • @ember/error
    • @ember/object
    • @ember/polyfills
    • @ember/routing
    • @ember/runloop
    • @ember/service
    • @ember/string
    • @ember/test
    • @ember/utils
    • ember-glimmer
    • jquery
  • Classes
    • Adapter
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Checkbox
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • ContainerProxyMixin
    • Controller
    • CoreObject
    • DataAdapter
    • Ember.Debug
    • Ember.Logger
    • Ember.MutableEnumerable
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberError
    • EmberObject
    • Engine
    • EngineInstance
    • Evented
    • GlobalsResolver
    • HashLocation
    • Helper
    • HistoryLocation
    • LinkComponent
    • Mixin
    • MutableArray
    • NoneLocation
    • ObjectProxy
    • Observable
    • PromiseProxyMixin
    • RSVP.EventTarget
    • RSVP.Promise
    • Route
    • Router
    • RouterService
    • Service
    • String
    • TextArea
    • TextField

Class String public


Defined in: packages/ember-runtime/lib/system/string.js:118
Module: @ember/string

Defines string helper methods including string formatting and localization. Unless EmberENV.EXTEND_PROTOTYPES.String is false these methods will also be added to the String.prototype as well.


Methods

camelize (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:235

str
String

The string to camelize.

returns
String

the camelized string.

Returns the lowerCamelCase form of a string.

'innerHTML'.camelize();          // 'innerHTML'
'action_name'.camelize();        // 'actionName'
'css-class-name'.camelize();     // 'cssClassName'
'my favorite items'.camelize();  // 'myFavoriteItems'
'My Favorite Items'.camelize();  // 'myFavoriteItems'
'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice'

capitalize (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:291

str
String

The string to capitalize.

returns
String

The capitalized string.

Returns the Capitalized form of a string

'innerHTML'.capitalize()         // 'InnerHTML'
'action_name'.capitalize()       // 'Action_name'
'css-class-name'.capitalize()    // 'Css-class-name'
'my favorite items'.capitalize() // 'My favorite items'
'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice'

classify (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:254

str
String

the string to classify

returns
String

the classified string

Returns the UpperCamelCase form of a string.

'innerHTML'.classify();          // 'InnerHTML'
'action_name'.classify();        // 'ActionName'
'css-class-name'.classify();     // 'CssClassName'
'my favorite items'.classify();  // 'MyFavoriteItems'
'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice'

dasherize (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:217

str
String

The string to dasherize.

returns
String

the dasherized string.

Replaces underscores, spaces, or camelCase with dashes.

'innerHTML'.dasherize();          // 'inner-html'
'action_name'.dasherize();        // 'action-name'
'css-class-name'.dasherize();     // 'css-class-name'
'my favorite items'.dasherize();  // 'my-favorite-items'
'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice'

decamelize (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:200

str
String

The string to decamelize.

returns
String

the decamelized string.

Converts a camelized string into all lower case separated by underscores.

'innerHTML'.decamelize();           // 'inner_html'
'action_name'.decamelize();        // 'action_name'
'css-class-name'.decamelize();     // 'css-class-name'
'my favorite items'.decamelize();  // 'my favorite items'

loc (str, formats) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:151

str
String

The string to format

formats
Array

Optional array of parameters to interpolate into string.

returns
String

formatted string

Formats the passed string, but first looks up the string in the localized strings hash. This is a convenient way to localize text. See Ember.String.fmt() for more information on formatting.

Note that it is traditional but not required to prefix localized string keys with an underscore or other character so you can easily identify localized strings.

Ember.STRINGS = {
  '_Hello World': 'Bonjour le monde',
  '_Hello %@ %@': 'Bonjour %@ %@'
};

Ember.String.loc("_Hello World");  // 'Bonjour le monde';
Ember.String.loc("_Hello %@ %@", ["John", "Smith"]);  // "Bonjour John Smith";

underscore (str) : String public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:272

str
String

The string to underscore.

returns
String

the underscored string.

More general than decamelize. Returns the lower_case_and_underscored form of a string.

'innerHTML'.underscore();          // 'inner_html'
'action_name'.underscore();        // 'action_name'
'css-class-name'.underscore();     // 'css_class_name'
'my favorite items'.underscore();  // 'my_favorite_items'
'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice'

w (str) : Array public

Module: @ember/string

Defined in packages/ember-runtime/lib/system/string.js:178

str
String

The string to split

returns
Array

array containing the split strings

Splits a string into separate units separated by spaces, eliminating any empty strings in the process. This is a convenience method for split that is mostly useful when applied to the String.prototype.

Ember.String.w("alpha beta gamma").forEach(function(key) {
  console.log(key);
});

// > alpha
// > beta
// > gamma
On this page


Methods

  • camelize
  • capitalize
  • classify
  • dasherize
  • decamelize
  • loc
  • underscore
  • w
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.