-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include_once: Added new include_once option (#181)
- Loading branch information
1 parent
584a689
commit 191570d
Showing
9 changed files
with
256 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
@@include_once('var.html', { | ||
"name": "haoxin", | ||
"age": 12345, | ||
"socials": { | ||
"fb": "facebook.com/include", | ||
"tw": "twitter.com/include" | ||
} | ||
}) | ||
@@include_once('var.html', { | ||
"name": "haoxin", | ||
"age": 12345, | ||
"socials": { | ||
"fb": "facebook.com/include", | ||
"tw": "twitter.com/include" | ||
} | ||
}) | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
@@include_once('var.html', { | ||
"name": "haoxin", | ||
"age": 12345, | ||
"socials": { | ||
"fb": "facebook.com/include", | ||
"tw": "twitter.com/include" | ||
} | ||
}) | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<label>haoxin</label> | ||
<label>12345</label> | ||
<strong>facebook.com/include</strong> | ||
<strong>twitter.com/include</strong> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<label>haoxin</label> | ||
<label>12345</label> | ||
<strong>facebook.com/include</strong> | ||
<strong>twitter.com/include</strong> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<label>@@name</label> | ||
<label>@@age</label> | ||
<strong>@@socials.fb</strong> | ||
<strong>@@socials.tw</strong> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
'use strict' | ||
|
||
const fileIncludePlugin = require('../lib') | ||
const Vinyl = require('vinyl') | ||
const should = require('should') | ||
const fs = require('fs') | ||
|
||
describe('## gulp-file-include', () => { | ||
var result = fs.readFileSync('test/fixtures-nested-once/result.html', 'utf8') | ||
var resultTwice = fs.readFileSync('test/fixtures-nested-once/result-twice.html', 'utf8') | ||
|
||
describe('# nested once arguments', () => { | ||
it('file', done => { | ||
var file = new Vinyl({ | ||
path: 'test/fixtures-nested-once/index.html', | ||
contents: fs.readFileSync('test/fixtures-nested-once/index.html') | ||
}) | ||
|
||
var stream = fileIncludePlugin() | ||
stream.on('data', newFile => { | ||
should.exist(newFile) | ||
should.exist(newFile.contents) | ||
|
||
String(newFile.contents).should.equal(result) | ||
done() | ||
}) | ||
|
||
stream.write(file) | ||
stream.end() | ||
}) | ||
|
||
it('stream', done => { | ||
var file = new Vinyl({ | ||
path: 'test/fixtures-nested-once/index.html', | ||
contents: fs.createReadStream('test/fixtures-nested-once/index.html') | ||
}) | ||
|
||
var stream = fileIncludePlugin() | ||
stream.on('data', newFile => { | ||
should.exist(newFile) | ||
should.exist(newFile.contents) | ||
|
||
String(newFile.contents).should.equal(result) | ||
done() | ||
}) | ||
|
||
stream.write(file) | ||
stream.end() | ||
}) | ||
}) | ||
|
||
describe('# nested once arguments twice', () => { | ||
it('file', done => { | ||
var file = new Vinyl({ | ||
path: 'test/fixtures-nested-once/index-twice.html', | ||
contents: fs.readFileSync('test/fixtures-nested-once/index-twice.html') | ||
}) | ||
|
||
var stream = fileIncludePlugin() | ||
stream.on('data', newFile => { | ||
should.exist(newFile) | ||
should.exist(newFile.contents) | ||
|
||
String(newFile.contents).should.equal(resultTwice) | ||
done() | ||
}) | ||
|
||
stream.write(file) | ||
stream.end() | ||
}) | ||
|
||
it('stream', done => { | ||
var file = new Vinyl({ | ||
path: 'test/fixtures-nested-once/index-twice.html', | ||
contents: fs.createReadStream('test/fixtures-nested-once/index-twice.html') | ||
}) | ||
|
||
var stream = fileIncludePlugin() | ||
stream.on('data', newFile => { | ||
should.exist(newFile) | ||
should.exist(newFile.contents) | ||
|
||
String(newFile.contents).should.equal(resultTwice) | ||
done() | ||
}) | ||
|
||
stream.write(file) | ||
stream.end() | ||
}) | ||
}) | ||
}) |