This addon provides a component for truncating text in an Ember application.
npm install ember-truncate
To get started, place the truncate-multiline component in one of your templates and provide a string to the text attribute.
The block form offers customization beyond that of the inline form and support for nested DOM nodes. Instead of supplying the text attribute, render text or elements into the target component. Use the button component to customize the more/less button, or exclude it to remove the button entirely. The isTruncated property provides access to the current state of truncation.
NB: It is recommended that you use the tilde ~ character to omit extra whitespace when using the block form.
The truncate-multiline component offers other functionality via attributes.
The number of lines at which the component truncates can be changed by setting the lines attribute. The default is 3 lines.
Programmatically controls expanding/collapsing the text. This attribute is especially useful when the button is omitted.
The truncate-multiline component uses actions to signal change in truncation state.
The onExpand action is triggered whenever the text is expanded.
The onCollapse action is triggered whenever the text is collapsed.
The onToggle action is triggered whenever the text is expanded or collapsed. The new truncation state is passed to the action: true for collapsed, false for expanded.
- fork this repository
git cloneyour forknpm install- make changes
npm testto verify tests pass for supported versions of Embergit pushchanges to your fork- open a pull request against this repository
ember testruns tests against the version of Ember listed inpackage.jsonember test --serverlivereloads tests in Chrome, making failrues easier to debugnpm testruns tests against all supported versions of Emberember try:eachruns tests against the latest versions of Ember (in addition to the supported Ember versions)