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
ember install ember-cli-string-helpers
Camelizes a string using Ember.String.camelize
.
Output: helloJimBob
Capitalizes a string using Ember.String.capitalize
.
Output: Hello jim bob
Classifies a string using Ember.String.classify
.
Output: HelloJimBob
Dasherizes a string using Ember.String.dasherize
.
Output: whats-that
Mark a string as safe for unescaped output with Ember templates using Ember.String.htmlSafe
.
Removes dashes and underscores from a string, capitalizes the first letter and makes the rest of the string lower case.
Output: Some string
Lowercases a string.
Output: people person's paper people
Capitalizes every word separated by a white space or a dash.
Output: My Big Fat Greek Wedding
Trim a string.
Output: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Truncates a string with a characterLimit and optionally adds an ellipsis to the end.
Output: Lorem ipsum dolor...
Underscores a string using Ember.String.underscore
.
Output: whats_that
Uppercases a string.
Output: LOUD NOISES
Splits a string on whitespace and/or turns multiple words into an array.
or:
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
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:
declare module '@glint/environment-ember-loose/registry' {
export default interface Registry
extends EmberCliStringHelpersRegistry {
// ...
}
}
import { camelize } from 'ember-cli-string-helpers';
<template>
{{camelize "hello jim bob"}}
</template>
This project is licensed under the MIT License.