Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rwu823/riot-hi-text

The highlight text compontent for Riot.js
https://github.com/rwu823/riot-hi-text

Last synced: about 1 month ago
JSON representation

The highlight text compontent for Riot.js

Awesome Lists containing this project

README

        

# The highlight text component for Riot.js

## Installation
npm ins --save-dev riot-hi-text

## Examples
### Basic

Import script, the standalone script files are in the `dist` .
```html

```
Webpack or Browserify:

```js
require('riot-hi-text')
```

Create tags

```html

Hello highlight text!!!!

```

```js
require('riot-hi-text')

var hiTextTags = riot.mount('hi-text')
hiTextTags.forEach(function(tag){
tag.setHighlight('h')
})
```

yield:
every `h` will warp with ``

```html

Hello highlight text!!!!

```

## Dynamic
```html

{text}
this.tags['hi-text'].text = 'hello hi text!!'

```

## Options

`opts['class-name']`

Custom class name, default is `highlight`

```html

```

`opts['case-sensitive'] `

Match word with case sensitive. default is `false`

```html

```
equal to
```html

```

## API

### setHighlight(word, [case_sensitive = false])
Set highlight with `word`

### clean()
Clean all highlight.

### hasMatched
`true` or `false`, change everytime after invoking `setHighlight()`

## Asynchronous
```html

{text}

var tag = this

$.ajax({
url: '/api/case'
})
.done(function(data){
tag.tags['h1-text'].text = data
tag.tags['h1-text'].update()
tag.tags['h1-text'].setHeightlight('hi')
})

```

## With chain
The API all return tag instance itself, so you can chain the method
```js
tag
.clean()
.setHighlight('Hi')
```