1.2.3 • Published 8 years ago
ember-text-highlight v1.2.3
Ember Text Highlight

This addon exposes a simple Ember.Helper that wraps matching parts of a text in a span with a stylable CSS class (mark).
It picks the algorithm that likely performs best in the current environment, making it up to twice as fast as the idiomatic implementation with regular expressions.

Usage
Pick one way to install the addon.
$ ember install ember-text-highlight $ yarn add ember-text-highlight --dev $ npm install ember-text-highlight --save-devWrap around your template strings
{{text-highlight content query=query}}Style
Lets say
contentisBryan BurkeandqueryisBry:{{text-highlight 'Bryan Burke' query='bry'}}The rendered HTML will look like this:
<span class="mark">Bry</span>an BurkeYou can now style the CSS class
.markaccording to your wishes and context.A good start might be the style you see in the demo video above:
.mark { padding: 0 !important; background-color: rgba(255, 238, 115, 0.59); }Twitter Bootstrap already ships a pre-styled
.markclass.
Contributing
- Fork repository
git clone <forked-repository-url>cd ember-text-highlightyarn install- Make sure everything works before you start:
yarn run test(Runsember try:eachto test against multiple Ember versions) - Improve something
- Re-run tests and adapt/expand
- Create a pull request 🙌