String helpers for Ember
npm install ember-cli-string-helpers!Download count all time



String helpers for Ember. Extracted from the great DockYard's ember-composable-helpers.
> [!WARNING]
> If you are using single file components you most likely do not need this addon as it's just a wrapper on @ember/string methods. You can import most methods directly from @ember/string in your components, or migrate to something like change-case.
* Ember.js v3.28 or above
* Ember CLI v4.4 or above
* Node.js v20 or above
``shell`
ember install ember-cli-string-helpers
- ember-cli-string-helpers
- Compatibility
- Installation
- Available helpers
- Usage
- camelize
- capitalize
- classify
- dasherize
- html-safe
- humanize
- lowercase
- titleize
- trim
- truncate
- underscore
- uppercase
- w
- Glint usage
- Template Tag usage
- See also
- License
#### camelize
Camelizes a string using Ember.String.camelize.
`hbs`
{{camelize "hello jim bob"}}
{{camelize stringWithDashes}}
Output: helloJimBob
#### capitalize
Capitalizes a string using Ember.String.capitalize.
`hbs`
{{capitalize "hello jim bob"}}
{{capitalize fullName}}
Output: Hello jim bob
#### classify
Classifies a string using Ember.String.classify.
`hbs`
{{classify "hello jim bob"}}
{{classify stringWithDashes}}
Output: HelloJimBob
#### dasherize
Dasherizes a string using Ember.String.dasherize.
`hbs`
{{dasherize "whatsThat"}}
{{dasherize phrase}}
Output: whats-that
#### html-safe
Mark a string as safe for unescaped output with Ember templates using Ember.String.htmlSafe.
`hbs`
{{html-safe "someString"}}
{{html-safe unsafeString}}
#### humanize
Removes dashes and underscores from a string, capitalizes the first letter and makes the rest of the string lower case.
`hbs`
{{humanize "some-string"}}
{{humanize phrase}}
Output: Some string
#### lowercase
Lowercases a string.
`hbs`
{{lowercase "People Person's Paper People"}}
{{lowercase phrase}}
Output: people person's paper people
#### titleize
Capitalizes every word separated by a white space or a dash.
`hbs`
{{titleize "my big fat greek wedding"}}
{{titleize phrase}}
Output: My Big Fat Greek Wedding
#### trim
Trim a string.
`hbs`
{{trim " Lorem ipsum dolor sit amet, consectetur adipiscing elit. "}}
{{trim phrase}}
Output: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
#### truncate
Truncates a string with a characterLimit and optionally adds an ellipsis to the end.
`hbs`
{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit." 20 true}}
{{truncate phrase characterLimit useEllipsis}}
Output: Lorem ipsum dolor...
#### underscore
Underscores a string using Ember.String.underscore.
`hbs`
{{underscore "whatsThat"}}
{{underscore phrase}}
Output: whats_that
#### uppercase
Uppercases a string.
`hbs`
{{uppercase "loud noises"}}
{{uppercase phrase}}
Output: LOUD NOISES
#### w
Splits a string on whitespace and/or turns multiple words into an array.
`hbs`
{{#each (w "First" "Second" "Last") as |rank|}}
Our {{rank}} place winner is ...
{{/each}}
or:
`hbs`
{{#each (w "First Second Last") as |rank|}}
Our {{rank}} place winner is ...
{{/each}}
See also: Ember w documentation
If you are using Glint and environment-ember-loose, you can add all the helpers to your app at once by adding
`ts`
import type EmberCliStringHelpersRegistry from 'ember-cli-string-helpers/template-registry';
to your app's e.g. types/glint.d.ts file, and making sure your registry extends from EmberCliStringHelpersRegistry:
`ts`
declare module '@glint/environment-ember-loose/registry' {
export default interface Registry
extends EmberCliStringHelpersRegistry {
// ...
}
}
`gjs
import { camelize } from 'ember-cli-string-helpers';
{{camelize "hello jim bob"}}
``
* ember-composable-helpers
* ember-math-helpers
* ember-truth-helpers
This project is licensed under the MIT License.