Skip to content

Commit

Permalink
Docs: add rcs.replace.pug docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Aug 28, 2018
1 parent 4742cc7 commit 5e51dfa
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/api/replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All replace methods take `Buffer` or `String`.

- [regex](#regex)
- [html](#html)
- [pug](#pug)
- [any](#any)
- [css](#css)
- [js](#js)
Expand All @@ -31,6 +32,7 @@ Options:
- espreeOptions: same as [replace.js](#js) options
- triggerClassAttributes `<Array>`: Array of string or regular expressions. Renames all classes with the matching string or regex. E.g. `[/data-*/ , 'custom-attr']` matches all data attributes and 'custom-attr'
- triggerIdAttributes `<Array>`: Same as triggerClassAttributes just for IDs

Example:

```js
Expand All @@ -44,6 +46,35 @@ const replacedHtml = rcs.replace.html('<div class="my-class"></div>');
// '<div class="a"></div>'
```

### pug

> Same as [rcs.replace.html](#html) just with [pug](https://pugjs.org/) templates
**rcs.replace.pug(code[, options])**

Parameters:
- code `<String>`
- same options as [rcs.replace.html](#html) `<Object>`

Example:

```js
const rcs = require('rcs-core');

// first set the id to replace
rcs.selectorLibrary.set('.my-class');

const replacedHtml = rcs.replace.pug(`
.my-class(attr='my attribute')
.another-class
`);
// output in pug:
// `
// .a(attr!='my attribute')
// .another-class
// `
```

### any

> Replaces all strings which matches the filled selectors
Expand Down

0 comments on commit 5e51dfa

Please sign in to comment.