kyleshay / ember-truncate

A generic component used to truncate text to a specified number of lines.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ember Truncate

Build Status npm version

This addon provides a component for truncating blocks of text.

Installation

  • npm install ember-truncate

Usage

To get started, place the truncate-multiline component in one of your templates and provide a string to the text attribute.

{{truncate-multiline text="Long text to truncate."}}

You can also use the block form instead of supplying the text attribute. The block form supports nested DOM nodes.

{{#truncate-multiline~}}
  Long text to truncate with <em><strong>really</strong> important</em> formatting.
{{~/truncate-multiline}}

It is recommended that you use the tilde ~ character to omit extra whitespace when using the block form.

The number of lines at which the component truncates can be changed by setting the lines attribute. The default is 3 lines.

{{truncate-multiline text="Long text to truncate." lines=5}}

Other attributes are available for advanced use. See the documentation in the source code for more details.

{{truncate-multiline text="Long text to truncate." truncate=booleanInParent showButton=false}}

{{truncate-multiline text="Long text to truncate." seeMoreButtonText="Show More" onExpand=(action "doSomeCoolThing")}}

Contributing

  • git clone this repository
  • npm install
  • bower install

Running Tests

  • ember test
  • ember test --server

About

A generic component used to truncate text to a specified number of lines.

License:MIT License


Languages

Language:JavaScript 94.1%Language:HTML 5.9%