From 9599a24594b61d4519facced89a76ad1ee440267 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:00:03 +0200 Subject: [PATCH 01/12] Updated handlebars to a more recent version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fee9f46..a756830 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "gulp-util": "^3.0.3", "through2": "^0.6.3", - "handlebars": ">=3.0.0" + "handlebars": ">=4.0.5" }, "devDependencies": { "mocha": "*" From 8918a8050edd9c8934dcfa605a73bbe902732977 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:11:08 +0200 Subject: [PATCH 02/12] Added test for failover partial blocks --- test/test.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 0742586..3507c7d 100644 --- a/test/test.js +++ b/test/test.js @@ -65,15 +65,15 @@ it('should compile Handlebars templates, and use batched partials', function (cb }); it('should compile Handlebars templates, and use batched NESTED partials', function (cb) { - var stream = template({}, { batch: ['test/partials'] }); + var stream = template({}, {}); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Mobile Header Goes Here'); + assert.equal(data.contents.toString(), 'Failover content'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{> mobile/header-test}}') + contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') })); stream.end(); @@ -148,3 +148,18 @@ it('should not require a default data object', function (cb) { stream.end(); }); + +it('should support failover partial blocks when no partial is provided', function (cb) { + var stream = template({}, { batch: ['test/partials/desktop', 'test/partials/mobile'] }); + + stream.on('data', function (data) { + assert.equal(data.contents.toString(), 'Desktop Header Goes Here'); + cb(); + }); + + stream.write(new gutil.File({ + contents: new Buffer('{{> desktop/header-test}}') + })); + + stream.end(); +}); \ No newline at end of file From 84063d304579839660e2c661e09f2a05f212f2ac Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:16:31 +0200 Subject: [PATCH 03/12] Removed extra line inserted in test.js --- test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.js b/test/test.js index 3507c7d..7ca441a 100644 --- a/test/test.js +++ b/test/test.js @@ -94,7 +94,6 @@ it('should compile Handlebars templates, and use multiple batched NESTED partial stream.end(); }); - it('should compile Handlebars templates with no helpers or partials', function (cb) { var stream = template( {people: ['foo', 'bar']}); From f4403d822a5145717a460439036c453e1760ed39 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:23:49 +0200 Subject: [PATCH 04/12] fixed errors introduced in test.js --- test/test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test.js b/test/test.js index 7ca441a..c32a72f 100644 --- a/test/test.js +++ b/test/test.js @@ -65,15 +65,15 @@ it('should compile Handlebars templates, and use batched partials', function (cb }); it('should compile Handlebars templates, and use batched NESTED partials', function (cb) { - var stream = template({}, {}); + var stream = template({}, { batch: ['test/partials'] }); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Failover content'); + assert.equal(data.contents.toString(), 'Mobile Header Goes Here'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') + contents: new Buffer('{{> mobile/header-test}}') })); stream.end(); @@ -94,6 +94,7 @@ it('should compile Handlebars templates, and use multiple batched NESTED partial stream.end(); }); + it('should compile Handlebars templates with no helpers or partials', function (cb) { var stream = template( {people: ['foo', 'bar']}); @@ -147,17 +148,16 @@ it('should not require a default data object', function (cb) { stream.end(); }); - it('should support failover partial blocks when no partial is provided', function (cb) { - var stream = template({}, { batch: ['test/partials/desktop', 'test/partials/mobile'] }); + var stream = template({}, {}); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Desktop Header Goes Here'); + assert.equal(data.contents.toString(), 'Failover content'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{> desktop/header-test}}') + contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') })); stream.end(); From ec7c2cff0c523448f1c57bc6434b523f089ebfae Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:23:49 +0200 Subject: [PATCH 05/12] Revert "fixed errors introduced in test.js" This reverts commit f4403d822a5145717a460439036c453e1760ed39. --- test/test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test.js b/test/test.js index c32a72f..7ca441a 100644 --- a/test/test.js +++ b/test/test.js @@ -65,15 +65,15 @@ it('should compile Handlebars templates, and use batched partials', function (cb }); it('should compile Handlebars templates, and use batched NESTED partials', function (cb) { - var stream = template({}, { batch: ['test/partials'] }); + var stream = template({}, {}); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Mobile Header Goes Here'); + assert.equal(data.contents.toString(), 'Failover content'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{> mobile/header-test}}') + contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') })); stream.end(); @@ -94,7 +94,6 @@ it('should compile Handlebars templates, and use multiple batched NESTED partial stream.end(); }); - it('should compile Handlebars templates with no helpers or partials', function (cb) { var stream = template( {people: ['foo', 'bar']}); @@ -148,16 +147,17 @@ it('should not require a default data object', function (cb) { stream.end(); }); + it('should support failover partial blocks when no partial is provided', function (cb) { - var stream = template({}, {}); + var stream = template({}, { batch: ['test/partials/desktop', 'test/partials/mobile'] }); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Failover content'); + assert.equal(data.contents.toString(), 'Desktop Header Goes Here'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') + contents: new Buffer('{{> desktop/header-test}}') })); stream.end(); From 0bd30d7a9ea41172ea6ebf41a9236ada83643701 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:11:08 +0200 Subject: [PATCH 06/12] Revert "Added test for failover partial blocks" This reverts commit 8918a8050edd9c8934dcfa605a73bbe902732977. --- test/test.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/test/test.js b/test/test.js index 7ca441a..d720ead 100644 --- a/test/test.js +++ b/test/test.js @@ -65,15 +65,15 @@ it('should compile Handlebars templates, and use batched partials', function (cb }); it('should compile Handlebars templates, and use batched NESTED partials', function (cb) { - var stream = template({}, {}); + var stream = template({}, { batch: ['test/partials'] }); stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Failover content'); + assert.equal(data.contents.toString(), 'Mobile Header Goes Here'); cb(); }); stream.write(new gutil.File({ - contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') + contents: new Buffer('{{> mobile/header-test}}') })); stream.end(); @@ -147,18 +147,3 @@ it('should not require a default data object', function (cb) { stream.end(); }); - -it('should support failover partial blocks when no partial is provided', function (cb) { - var stream = template({}, { batch: ['test/partials/desktop', 'test/partials/mobile'] }); - - stream.on('data', function (data) { - assert.equal(data.contents.toString(), 'Desktop Header Goes Here'); - cb(); - }); - - stream.write(new gutil.File({ - contents: new Buffer('{{> desktop/header-test}}') - })); - - stream.end(); -}); \ No newline at end of file From afc837ac39c1d29cb0799c70d6df11cdf3304e28 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:32:11 +0200 Subject: [PATCH 07/12] Added test for failover partial blocks --- test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.js b/test/test.js index d720ead..0742586 100644 --- a/test/test.js +++ b/test/test.js @@ -94,6 +94,7 @@ it('should compile Handlebars templates, and use multiple batched NESTED partial stream.end(); }); + it('should compile Handlebars templates with no helpers or partials', function (cb) { var stream = template( {people: ['foo', 'bar']}); From 1d0d58bbeafa2e9d232075d6a64ac649410306ce Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:35:46 +0200 Subject: [PATCH 08/12] Added test for failover partial blocks --- test/test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test.js b/test/test.js index 0742586..a27ef4d 100644 --- a/test/test.js +++ b/test/test.js @@ -148,3 +148,18 @@ it('should not require a default data object', function (cb) { stream.end(); }); + +it('should support failover partial blocks when no partial is provided', function (cb) { + var stream = template({}, {}); + + stream.on('data', function (data) { + assert.equal(data.contents.toString(), 'Failover content'); + cb(); + }); + + stream.write(new gutil.File({ + contents: new Buffer('{{#> myPartial }}Failover content{{/myPartial}}') + })); + + stream.end(); +}); \ No newline at end of file From ac89107d4427e3f3fdd90cb405e0432c43ad3d0a Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 02:38:33 +0200 Subject: [PATCH 09/12] Added newline to test.js --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index a27ef4d..e6e640b 100644 --- a/test/test.js +++ b/test/test.js @@ -162,4 +162,4 @@ it('should support failover partial blocks when no partial is provided', functio })); stream.end(); -}); \ No newline at end of file +}); From 2c3f27f770f42f26db7d4cad5bb12bf27e1b574d Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 03:29:06 +0200 Subject: [PATCH 10/12] Added support for gulp-data, data can be passed along with the file and will be merged with any data sent via data parameter. --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 95c7b85..174d140 100644 --- a/index.js +++ b/index.js @@ -105,6 +105,11 @@ function handlebars(data, opts) { return through.obj(function (file, enc, cb) { + + if (file.data) { + data = extend(file.data, data); + } + var _data = extend({}, data); if (file.isNull()) { From 21f057ee8cf5e4c61eb256832b41dde4de5a9db7 Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 03:29:06 +0200 Subject: [PATCH 11/12] Revert "Added support for gulp-data, data can be passed along with the file and will be merged with any data sent via data parameter." This reverts commit 2c3f27f770f42f26db7d4cad5bb12bf27e1b574d. --- index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/index.js b/index.js index 174d140..95c7b85 100644 --- a/index.js +++ b/index.js @@ -105,11 +105,6 @@ function handlebars(data, opts) { return through.obj(function (file, enc, cb) { - - if (file.data) { - data = extend(file.data, data); - } - var _data = extend({}, data); if (file.isNull()) { From 72067f26f13b7ffb56c1524f981212492b9da32c Mon Sep 17 00:00:00 2001 From: Pieter Botha Date: Tue, 22 Mar 2016 03:29:06 +0200 Subject: [PATCH 12/12] Revert "Added support for gulp-data, data can be passed along with the file and will be merged with any data sent via data parameter." This reverts commit 2c3f27f770f42f26db7d4cad5bb12bf27e1b574d.