Class String
publicDefines 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.
camelize (str) String public
Defined in packages/@ember/string/index.ts:213
- str
- String
The string to camelize.
- returns
- String
the camelized string.
Returns the lowerCamelCase form of a string.
import { camelize } from '@ember/string';
camelize('innerHTML'); // 'innerHTML'
camelize('action_name'); // 'actionName'
camelize('css-class-name'); // 'cssClassName'
camelize('my favorite items'); // 'myFavoriteItems'
camelize('My Favorite Items'); // 'myFavoriteItems'
camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
capitalize (str) String public
Defined in packages/@ember/string/index.ts:281
- str
- String
The string to capitalize.
- returns
- String
The capitalized string.
Returns the Capitalized form of a string
import { capitalize } from '@ember/string';
capitalize('innerHTML') // 'InnerHTML'
capitalize('action_name') // 'Action_name'
capitalize('css-class-name') // 'Css-class-name'
capitalize('my favorite items') // 'My favorite items'
capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
classify (str) String public
Defined in packages/@ember/string/index.ts:236
- str
- String
the string to classify
- returns
- String
the classified string
Returns the UpperCamelCase form of a string.
import { classify } from '@ember/string';
classify('innerHTML'); // 'InnerHTML'
classify('action_name'); // 'ActionName'
classify('css-class-name'); // 'CssClassName'
classify('my favorite items'); // 'MyFavoriteItems'
classify('private-docs/owner-invoice'); // 'PrivateDocs/OwnerInvoice'
dasherize (str) String public
Defined in packages/@ember/string/index.ts:191
- str
- String
The string to dasherize.
- returns
- String
the dasherized string.
Replaces underscores, spaces, or camelCase with dashes.
import { dasherize } from '@ember/string';
dasherize('innerHTML'); // 'inner-html'
dasherize('action_name'); // 'action-name'
dasherize('css-class-name'); // 'css-class-name'
dasherize('my favorite items'); // 'my-favorite-items'
dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
decamelize (str) String public
Defined in packages/@ember/string/index.ts:170
- str
- String
The string to decamelize.
- returns
- String
the decamelized string.
Converts a camelized string into all lower case separated by underscores.
import { decamelize } from '@ember/string';
decamelize('innerHTML'); // 'inner_html'
decamelize('action_name'); // 'action_name'
decamelize('css-class-name'); // 'css-class-name'
decamelize('my favorite items'); // 'my favorite items'
underscore (str) String public
Defined in packages/@ember/string/index.ts:258
- 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.
import { underscore } from '@ember/string';
underscore('innerHTML'); // 'inner_html'
underscore('action_name'); // 'action_name'
underscore('css-class-name'); // 'css_class_name'
underscore('my favorite items'); // 'my_favorite_items'
underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
w (str) Array public
Defined in packages/@ember/string/index.ts:144
- 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
.
import { w } from '@ember/string';
w("alpha beta gamma").forEach(function(key) {
console.log(key);
});
// > alpha
// > beta
// > gamma