A new start

This commit is contained in:
2018-11-24 14:43:59 +01:00
commit 3c32c8a37a
24054 changed files with 1376258 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<html>
<head>
<script src="{{baseUrl}}/app.js"></script>
</head>
<body>
<h1>{{pageTitle}}</h1>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<html>
<head>
<script src="/app.js"></script>
</head>
<body>
<h1></h1>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<html>
<head>
<script src="http://www.somewhere.com/app.js"></script>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

View File

@@ -0,0 +1,4 @@
module.exports = {
baseUrl: 'http://www.somewhere.com',
pageTitle: 'Hello World!'
};

View File

@@ -0,0 +1,3 @@
html {
background-color: [[primaryColor]];
}

View File

@@ -0,0 +1,3 @@
html {
background-color: #A6A6A6;
}

View File

@@ -0,0 +1,3 @@
module.exports = {
primaryColor: '#A6A6A6'
};

View File

@@ -0,0 +1,4 @@
This is a test of hierarchical tokens.
root.name={{root.name}}
root.first.name={{root.first.name}}
root.first.age={{root.first.age}}

View File

@@ -0,0 +1,4 @@
This is a test of hierarchical tokens.
root.name=
root.first.name=
root.first.age=

View File

@@ -0,0 +1,4 @@
This is a test of hierarchical tokens.
root.name=This is the root name
root.first.name=First's Name
root.first.age=99

View File

@@ -0,0 +1,9 @@
module.exports = {
root: {
name: 'This is the root name',
first: {
name: 'First\'s Name',
age: 99
}
}
};

View File

@@ -0,0 +1,4 @@
function test() {
var val1 = {{val1}};
var val2 = [[val2]];
}

View File

@@ -0,0 +1,4 @@
function test() {
var val1 = 123;
var val2 = [[val2]];
}

View File

@@ -0,0 +1,4 @@
function test() {
var val1 = {{val1}};
var val2 = 789;
}

View File

@@ -0,0 +1,4 @@
module.exports = {
val1: 123,
val2: 789
};

View File

@@ -0,0 +1,4 @@
function test() {
var val1 = '{{myVar}}';
var val2 = [[val2]];
}

View File

@@ -0,0 +1,4 @@
function test() {
var val1 = 'hello';
var val2 = [[val2]];
}

View File

@@ -0,0 +1,3 @@
function test() {
var val2 = '{{myVar}}';
}

View File

@@ -0,0 +1,3 @@
function test() {
var val2 = '{"hello":{"nested":"object"}}';
}

View File

@@ -0,0 +1,10 @@
{{doctype}}
<html>
<head>
{{head/title.html}}
</head>
<body>
{{body/heading.html}}
{{body/paragraph.html}}
</body>
</html>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Lorem ipsum</title>
</head>
<body>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam et turpis eros.</p>
</body>
</html>

View File

@@ -0,0 +1,10 @@
module.exports = {
'doctype': '<!DOCTYPE html>',
'head': {
'title.html': '<title>Lorem ipsum</title>'
},
'body': {
'heading.html': '<h1>Lorem ipsum</h1>',
'paragraph.html': '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam et turpis eros.</p>'
}
};

View File

@@ -0,0 +1,7 @@
function test() {
var val1 = '{{myVar}}';
var val2 = '{{array}}';
var val3 = '{{array[0]}}';
var val4 = '{{array[1]}}';
var val5 = '{{hello}}';
}

View File

@@ -0,0 +1,7 @@
function test() {
var val1 = 'test';
var val2 = '["Headline 1","Headline 2","Headline 3"]';
var val3 = 'Headline 1';
var val4 = 'Headline 2';
var val5 = '{"nested":"object"}';
}

175
node_modules/gulp-token-replace/test/tests.js generated vendored Normal file
View File

@@ -0,0 +1,175 @@
var should = require('should');
var fs = require("fs");
var es = require('event-stream');
var gulp = require("gulp");
var replace = require('../');
var concat = require('concat-stream');
describe('source1.html', function() {
var source1_tokens = require('./fixtures/source1_tokens.js');
describe('with replace()', function() {
it('should match source1_output1.html', function(cb) {
TestReplace('source1.html', null, 'source1_output1.html', true, cb);
});
});
describe('with replace({preserveUnknownTokens: true})', function() {
it('should match source1.html', function(cb) {
TestReplace('source1.html', {preserveUnknownTokens: true}, 'source1.html', true, cb);
});
});
describe('with replace({preserveUnknownTokens: false})', function() {
it('should match source1_output1.html', function(cb) {
TestReplace('source1.html', {preserveUnknownTokens: false}, 'source1_output1.html', true, cb);
});
it('should NOT match source1.html', function(cb) {
TestReplace('source1.html', {preserveUnknownTokens: false}, 'source1.html', false, cb);
});
});
describe('with replace({tokens: source1_tokens})', function() {
it('should match source1_output2.html', function(cb) {
TestReplace('source1.html', {tokens: source1_tokens}, 'source1_output2.html', true, cb);
});
});
describe('with replace({prefix: \'{{\', tokens: source1_tokens})', function() {
it('should match source1_output2.html', function(cb) {
TestReplace('source1.html', {prefix: '{{', tokens: source1_tokens}, 'source1_output2.html', true, cb);
});
});
describe('with replace({suffix: \'}}\', tokens: source1_tokens})', function() {
it('should match source1_output2.html', function(cb) {
TestReplace('source1.html', {suffix: '}}', tokens: source1_tokens}, 'source1_output2.html', true, cb);
});
});
describe('with replace({prefix: \'{{\', suffix: \'}}\', tokens: source1_tokens})', function() {
it('should match source1_output2.html', function(cb) {
TestReplace('source1.html', {prefix: '{{', suffix: '}}', tokens: source1_tokens}, 'source1_output2.html', true, cb);
});
});
});
describe('source2.css', function() {
var source2_tokens = require('./fixtures/source2_tokens.js');
describe('with replace()', function() {
it('should match source2.css', function(cb) {
TestReplace('source2.css', null, 'source2.css', true, cb);
});
});
describe('with replace({prefix: \'[[\', suffix: \']]\', tokens: source2_tokens})', function() {
it('should match source2_output1.css', function(cb) {
TestReplace('source2.css', {prefix: '[[', suffix: ']]', tokens: source2_tokens}, 'source2_output1.css', true, cb);
});
});
});
describe('source3.txt', function() {
var source3_tokens = require('./fixtures/source3_tokens.js');
describe('with replace({preserveUnknownTokens: true})', function() {
it('should match source3.txt', function(cb) {
TestReplace('source3.txt', {preserveUnknownTokens: true}, 'source3.txt', true, cb);
});
});
describe('with replace({preserveUnknownTokens: false})', function() {
it('should match source3_output1.txt', function(cb) {
TestReplace('source3.txt', {preserveUnknownTokens: false}, 'source3_output1.txt', true, cb);
});
});
describe('with replace({tokens: source3_tokens})', function() {
it('should match source3_output2.txt', function(cb) {
TestReplace('source3.txt', {tokens: source3_tokens}, 'source3_output2.txt', true, cb);
});
});
});
describe('source4.js', function() {
var source4_tokens = require('./fixtures/source4_tokens.js');
describe('with replace({tokens: source4_tokens, preserveUnknownTokens: true})', function() {
it('should match source4_output1.js', function(cb) {
TestReplace('source4.js', {tokens: source4_tokens, preserveUnknownTokens: true}, 'source4_output1.js', true, cb);
});
});
describe('with replace({prefix: \'[[\', suffix: \']]\', tokens: source4_tokens})', function() {
it('should match source4_output2.js', function(cb) {
TestReplace('source4.js', {prefix: '[[', suffix: ']]', tokens: source4_tokens, preserveUnknownTokens: true}, 'source4_output2.js', true, cb);
});
});
});
describe('source5.js', function() {
describe('Simple replace case {tokens: myvar:"hello"}', function() {
it('should match source5_output1.js', function(cb) {
TestReplace('source5.js', {tokens: {myVar:'hello'}, preserveUnknownTokens: true}, 'source5_output1.js', true, cb);
});
});
});
describe('source6.js', function() {
describe('A more complex case where the token value is an object {tokens: myVar:{"hello":{"nested":"object"}}}', function() {
it('should match source6_output1.js', function(cb) {
TestReplace('source6.js', {tokens: {myVar:{"hello":{"nested":"object"}}}, preserveUnknownTokens: true}, 'source6_output1.js', true, cb);
});
});
});
describe('source7.html', function() {
var source7_tokens = require('./fixtures/source7_tokens.js');
describe('with replace({tokens: source7_tokens})', function() {
it('should NOT match source7_output1.html', function(cb) {
TestReplace('source7.html', {tokens: source7_tokens}, 'source7_output1.html', false, cb);
});
});
describe('with replace({delimiter: \'.\', tokens: source7_tokens})', function() {
it('should NOT match source7_output1.html', function(cb) {
TestReplace('source7.html', {delimiter: '.', tokens: source7_tokens}, 'source7_output1.html', false, cb);
});
});
describe('with replace({delimiter: \'/\', tokens: source7_tokens})', function() {
it('should match source7_output1.html', function(cb) {
TestReplace('source7.html', {delimiter: '/', tokens: source7_tokens}, 'source7_output1.html', true, cb);
});
});
});
describe('source8.js', function() {
describe('Nested Array case', function() {
it('should match source8_output1.js', function(cb) {
TestReplace('source8.js', {tokens: {"myVar": "test", "array": [ "Headline 1", "Headline 2", "Headline 3" ], "hello":{"nested":"object"}}, preserveUnknownTokens: true}, 'source8_output1.js', true, cb);
});
});
});
function TestReplace(sourceFile, options, testFile, shouldEqual, cb) {
fs.readFile("./test/fixtures/" + testFile, function(err, expectedOutput) {
if (err) { return cb(err); }
function _assertOutput(output, expectedOutput) {
if (shouldEqual) {
console.log(output, 'should equal', expectedOutput);
output.should.equal(expectedOutput);
} else {
console.log(output, 'should not equal', expectedOutput);
output.should.not.equal(expectedOutput);
}
cb();
}
gulp.src("test/fixtures/" + sourceFile)
.pipe(replace(options))
.pipe(es.through(function(file) {
if (file.isStream()) {
file.contents.pipe(concat(function(output) {
_assertOutput(String(output), String(expectedOutput));
}));
} else if (file.isBuffer()) {
_assertOutput(String(file.contents), String(expectedOutput));
} else {
cb(new Error('unknown file type'));
}
}));
});
}