Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/jae-jae/gulp-insert-string-into-tag

gulp插入字符串到指定标签之间的插件
https://github.com/jae-jae/gulp-insert-string-into-tag

Last synced: about 1 month ago
JSON representation

gulp插入字符串到指定标签之间的插件

Awesome Lists containing this project

README

        

# gulp-insert-string-into-tag
gulp插入字符串到指定标签之间的插件

## 安装
```
npm install gulp-insert-string-into-tag
```

## 用法
`gulpfile.js`
```javascript
var gulp = require('gulp');
var insertString = require('gulp-insert-string-into-tag');

gulp.task('default', function () {
return gulp.src('index.html')
.pipe(insertString.append({
startTag:'',
endTag:'
',
string:'append string'
}))
.pipe(insertString.prepend({
startTag:'',
endTag:'',
string:'prepend string'
}))
.pipe(gulp.dest('dist'));
});
```
`index.html`
```html


This is String

This is other String

```
### 输出结果
`dist/index.html`
```html



This is String

append string


prepend string

This is other String


```
## API
### Function 方法
- insertString.append(opts) 追加字符串到标签之间的最后面
- insertString.prepend(opts) 追加字符串到标签之间的最前面

### opts 选项
- startTag 开始标记,可以是任意字符串
- endTag 结束标记,可以是任意字符串
- string 待追加的字符串