Repository: haoxins/gulp-file-include
Branch: main
Commit: d444c9bcf6e9
Files: 101
Total size: 63.5 KB
Directory structure:
gitextract_ccu95132/
├── .editorconfig
├── .gitignore
├── .npmrc
├── .travis.yml
├── LICENSE
├── Readme.md
├── example/
│ ├── a/
│ │ ├── a1.txt
│ │ └── a2.txt
│ ├── b/
│ │ ├── b1.txt
│ │ └── b2.txt
│ ├── c/
│ │ └── c.txt
│ ├── conditional.txt
│ ├── gulpfile.js
│ ├── index.txt
│ └── result/
│ └── index.txt
├── lib/
│ ├── indent.js
│ ├── index.js
│ ├── replace-function.js
│ ├── replace-operator.js
│ └── replace-variable.js
├── package.json
└── test/
├── .editorconfig
├── edge-case.js
├── error.js
├── filters.js
├── fixtures/
│ ├── arr-result.html
│ ├── arr.html
│ ├── index-01.html
│ ├── index-02.html
│ ├── index-03.html
│ ├── index-04.js
│ ├── index-05.html
│ ├── index-handler-options.html
│ ├── index-markdown-rot13.html
│ ├── index-markdown.html
│ ├── result.html
│ ├── result.js
│ ├── sameprefix-result.html
│ ├── sameprefix-var.html
│ ├── sameprefix.html
│ ├── var.html
│ ├── var.rot13.html
│ ├── view.html
│ ├── view.md
│ └── view.rot13.md
├── fixtures-edge-case/
│ ├── a.html
│ ├── b.html
│ ├── commented-inclusion-result.html
│ ├── commented-inclusion.html
│ ├── dangerous.txt
│ ├── index.html
│ ├── recursion.html
│ ├── result.html
│ ├── without-trailing-newline-result.txt
│ └── without-trailing-newline.txt
├── fixtures-error/
│ ├── for.html
│ └── if.html
├── fixtures-flatten/
│ ├── index.html
│ └── result.html
├── fixtures-indent/
│ ├── index.html
│ ├── result.html
│ ├── sub-sub.html
│ └── sub.html
├── fixtures-nested/
│ ├── index.html
│ ├── result.html
│ └── var.html
├── fixtures-nested-once/
│ ├── index-twice.html
│ ├── index.html
│ ├── result-twice.html
│ ├── result.html
│ └── var.html
├── fixtures-operator/
│ ├── index.html
│ ├── result-index.html
│ ├── result-suffix.html
│ └── suffix.html
├── fixtures-recursion/
│ ├── index.txt
│ ├── result.txt
│ ├── sub/
│ │ ├── a.txt
│ │ └── b.txt
│ └── var.txt
├── fixtures-suffix/
│ ├── index.html
│ └── var.html
├── fixtures-variable/
│ ├── index-suffix.html
│ ├── index.html
│ └── result.html
├── fixtures-webroot-variable/
│ ├── html-head.html
│ ├── index.html
│ ├── result.html
│ └── sub/
│ ├── home-link.html
│ ├── index.html
│ └── result.html
├── flatten.js
├── indent.js
├── index.js
├── nested-once.js
├── nested.js
├── operator.js
├── plugin-indent.js
├── recursion.js
├── variable.js
└── webroot-variable.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
root = true
[*.{html,js}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
================================================
FILE: .gitignore
================================================
package-lock.json
npm-debug.log
node_modules/
.DS_Store
coverage/
================================================
FILE: .npmrc
================================================
package-lock=false
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- 16
script: "npm run test-travis"
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020 Xin Hao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Readme.md
================================================
[![NPM version][npm-img]][npm-url]
[![Build status][travis-img]][travis-url]
[![Test coverage][coveralls-img]][coveralls-url]
[![License][license-img]][license-url]
[![Dependency status][david-img]][david-url]
[![Gitter][gitter-img]][gitter-url]
# gulp-file-include
a [gulp](https://github.com/gulpjs/gulp) plugin for file includes
## Installation
```bash
npm install --save-dev gulp-file-include
```
## API
```js
const fileinclude = require('gulp-file-include');
```
### fileinclude([prefix])
#### prefix
Type: `string`
Default: `'@@'`
### fileinclude([options])
#### options
Type: `object`
##### options.prefix
Type: `string`
Default: `'@@'`
##### options.suffix
Type: `string`
Default: `''`
##### options.basepath
Type: `string`
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`
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
```html
lorem ipsum...
" }, { "title": "Another post", "text": "lorem ipsum...
" }, { "title": "One more post", "text": "lorem ipsum...
" } ]) ``` loop-article.html ```htmllorem ipsum...
" }, { "title": "Another post", "text": "lorem ipsum...
" }, { "title": "One more post", "text": "lorem ipsum...
" } ] ``` loop-article.html ```html @@loop("loop-article.html", "data.json") ``` ### `webRoot` built-in context variable The `webRoot` field of the context contains the relative path from the source document to the source root (unless the value is already set in the context options). support/contact/index.html ```html