Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-file-include

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-file-include - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

3

lib/index.js

@@ -175,3 +175,4 @@ 'use strict'

// clean filename var and define path
var jsonfile = file.base + args[3].replace(/^('|")/, '').replace(/('|")$/, '')
var jsonPath = args[3].replace(/^('|")/, '').replace(/('|")$/, '');
var jsonfile = path.join(file.base, jsonPath);
// check if json file exists

@@ -178,0 +179,0 @@ if (fs.existsSync(jsonfile)) {

{
"name": "gulp-file-include",
"version": "2.1.0",
"version": "2.1.1",
"description": "a gulp plugin for file include",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

},
"repository": "coderhaoxin/gulp-file-include",
"repository": "haoxins/gulp-file-include",
"keywords": [

@@ -36,3 +36,3 @@ "gulpplugin",

"markdown": "^0.5.0",
"mocha": "^6.2.0",
"mocha": "^6.2.2",
"should": "^13.2.3"

@@ -39,0 +39,0 @@ },

@@ -8,49 +8,73 @@ [![NPM version][npm-img]][npm-url]

### gulp-file-include
a plugin of gulp for file include
# gulp-file-include
a [gulp](https://github.com/gulpjs/gulp) plugin for file includes
### install
## Installation
```bash
npm install gulp-file-include
npm install --save-dev gulp-file-include
```
### options
## API
* options - type: `string`, just as prefix, default `@@`, and basepath is default `@file`
```js
fileinclude('@@')
const fileinclude = require('gulp-file-include');
```
* options - type: `object`
- prefix: `string`, default `@@`
- suffix: `string`, default `''`
- basepath: `string`, default `@file`, it could be `@root`, `@file`, `your-basepath`
- filters: `object`, filters of include content
- context: `object`, context of `if` statement
- indent: `boolean`, default `false`
### fileinclude([prefix])
* options.basepath - type: `string`, it could be
- `@root`, include file relative to the dir where `gulp` running in
- `@file`, include file relative to the dir where `file` in [example](example)
- `your-basepath` include file relative to the basepath you give
#### prefix
```js
fileinclude({
prefix: '@@',
basepath: '@file'
})
```
Type: `string`<br>
Default: `'@@'`
```js
fileinclude({
prefix: '@@',
basepath: '/home/'
})
```
### fileinclude([options])
### example
#### options
* @@include options - type: `JSON`
Type: `object`
##### options.prefix
Type: `string`<br>
Default: `'@@'`
##### options.suffix
Type: `string`<br>
Default: `''`
##### options.basepath
Type: `string`<br>
Default: `'@file'`
Possible values:
- `'@file'`: include file relative to the dir in which `file` resides ([example](#include-options---type-json))
- `'@root'`: include file relative to the dir in which `gulp` is running
- `path/to/dir`: include file relative to the basepath you provide
##### options.filters
Type: `object`<br>
Default: `false`
Filters of include content.
##### options.context
Type: `object`
Default: `{}`
Context of `if` statement.
##### options.indent
Type: `boolean`
Default: `false`
## Examples
### @@include options - type: `JSON`
index.html

@@ -89,4 +113,4 @@ ```html

```js
var fileinclude = require('gulp-file-include'),
gulp = require('gulp');
const fileinclude = require('gulp-file-include');
const gulp = require('gulp');

@@ -103,3 +127,3 @@ gulp.task('fileinclude', function() {

and the result is:
result:
```html

@@ -120,2 +144,3 @@ <!DOCTYPE html>

index.html
```html

@@ -140,6 +165,7 @@ <!DOCTYPE html>

gulpfile.js
```js
var fileinclude = require('gulp-file-include'),
markdown = require('markdown'),
gulp = require('gulp');
const fileinclude = require('gulp-file-include');
const markdown = require('markdown');
const gulp = require('gulp');

@@ -159,11 +185,4 @@ gulp.task('fileinclude', function() {

```js
fileinclude({
context: {
name: 'test'
}
});
index.html
```
```
@@include('some.html', { "nav": true })

@@ -176,8 +195,7 @@

### `for` statement
gulpfile.js
```js
fileinclude({
context: {
arr: ['test1', 'test2']
name: 'test'
}

@@ -187,2 +205,5 @@ });

### `for` statement
index.html
```html

@@ -196,6 +217,14 @@ <ul>

gulpfile.js
```js
fileinclude({
context: {
arr: ['test1', 'test2']
}
});
```
### `loop` statement
* index.html
index.html
```html

@@ -211,4 +240,3 @@ <body>

* loop-article.html
loop-article.html
```html

@@ -221,6 +249,5 @@ <article>

### `loop` statement + data.json
### `loop` statement + `data.json`
data.json
```js

@@ -234,3 +261,3 @@ [

* loop-article.html
loop-article.html
```html

@@ -247,6 +274,3 @@ <body>

### example
support/contact/index.html
```html

@@ -266,4 +290,3 @@ <!DOCTYPE html>

and the result is:
result:
```html

@@ -270,0 +293,0 @@ <!DOCTYPE html>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc