From 88c24c9b0adb0c83f22cbd0d6acbb8a4741135db Mon Sep 17 00:00:00 2001 From: Nik Voss Date: Thu, 13 Feb 2014 22:35:26 +0000 Subject: [PATCH 01/18] support for handlebars templates --- lib/helpers/raw.js | 2 +- lib/template/processors/hbs.js | 28 ++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 lib/template/processors/hbs.js diff --git a/lib/helpers/raw.js b/lib/helpers/raw.js index 5a0bd006b..b04454be6 100644 --- a/lib/helpers/raw.js +++ b/lib/helpers/raw.js @@ -13,7 +13,7 @@ var TerraformError = exports.TerraformError = require("../error").TerraformError */ var processors = exports.processors = { - "html": ["jade", "ejs", "md"], + "html": ["jade", "ejs", "md", "hbs"], "css" : ["styl", "less", "scss", "sass"], "js" : ["coffee"] } diff --git a/lib/template/processors/hbs.js b/lib/template/processors/hbs.js new file mode 100644 index 000000000..988f0d9d9 --- /dev/null +++ b/lib/template/processors/hbs.js @@ -0,0 +1,28 @@ +var Handlebars = require('handlebars') +var TerraformError = require("../../error").TerraformError + +module.exports = function(fileContents, options){ + + return { + compile: function(){ + return Handlebars.compile(fileContents.toString(), options) + }, + + parseError: function(error){ + + var arr = error.message.split("\n") + var path_arr = arr[0].split(":") + + error.lineno = parseInt(error.lineno || path_arr[path_arr.length -1] || -1) + error.message = arr[arr.length - 1] + error.name = error.name + error.source = "Handlebars" + error.dest = "HTML" + error.filename = error.path || options.filename + error.stack = fileContents.toString() + + return new TerraformError(error) + } + } + +} diff --git a/package.json b/package.json index d74702f8f..469472948 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "less": "2.5.0", "stylus": "0.47.3", "minify": "git://github.com/kennethormandy/minify#v0.3.0", - "autoprefixer": "5.1.0" + "autoprefixer": "5.1.0", + "handlebars": "1.3.0" }, "devDependencies": { "mocha": "1.8.2", From d37a4fb9af85e010ecc93e4f4d5d3d1acf987be4 Mon Sep 17 00:00:00 2001 From: Marios Antonoudiou Date: Wed, 24 Sep 2014 13:10:12 +0000 Subject: [PATCH 02/18] Add handlebars (.hbs) support --- lib/template/processors/hbs.js | 2 +- package.json | 2 +- test/fixtures/templates/content.hbs | 1 + test/helpers.js | 17 +++++++++-------- test/templates.js | 10 ++++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/templates/content.hbs diff --git a/lib/template/processors/hbs.js b/lib/template/processors/hbs.js index 988f0d9d9..8222ca82c 100644 --- a/lib/template/processors/hbs.js +++ b/lib/template/processors/hbs.js @@ -16,7 +16,7 @@ module.exports = function(fileContents, options){ error.lineno = parseInt(error.lineno || path_arr[path_arr.length -1] || -1) error.message = arr[arr.length - 1] error.name = error.name - error.source = "Handlebars" + error.source = "HBS" error.dest = "HTML" error.filename = error.path || options.filename error.stack = fileContents.toString() diff --git a/package.json b/package.json index 469472948..86c6fa968 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "stylus": "0.47.3", "minify": "git://github.com/kennethormandy/minify#v0.3.0", "autoprefixer": "5.1.0", - "handlebars": "1.3.0" + "handlebars": "^2.0.0" }, "devDependencies": { "mocha": "1.8.2", diff --git a/test/fixtures/templates/content.hbs b/test/fixtures/templates/content.hbs new file mode 100644 index 000000000..1a614b8d5 --- /dev/null +++ b/test/fixtures/templates/content.hbs @@ -0,0 +1 @@ +

Hello! This is {{!-- should be invisible --}}Handlebars!

diff --git a/test/helpers.js b/test/helpers.js index f7dbf3075..da2603190 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -9,8 +9,8 @@ describe("helpers", function(){ it('should return all possible file names for html ordered by priority.', function(done){ var list = polymer.helpers.buildPriorityList('index.html') list.should.be.an.instanceOf(Array) - list.should.have.lengthOf(6) - var plist = "index.jade, index.ejs, index.md, index.html.jade, index.html.ejs, index.html.md".split(', ') + list.should.have.lengthOf(8) + var plist = "index.jade, index.ejs, index.md, index.hbs, index.html.jade, index.html.ejs, index.html.md, index.html.hbs".split(', ') list.should.eql(plist) done() }) @@ -26,27 +26,28 @@ describe("helpers", function(){ it('should build priority list assuming template file when unknown.', function(done){ var list = polymer.helpers.buildPriorityList('feed.xml') list.should.be.an.instanceOf(Array) - list.should.have.lengthOf(3) - list.should.eql('feed.xml.jade, feed.xml.ejs, feed.xml.md'. split(', ')) + list.should.have.lengthOf(4) + list.should.eql('feed.xml.jade, feed.xml.ejs, feed.xml.md, feed.xml.hbs'. split(', ')) done() }) it('should look for templates on json files.', function(done){ var list = polymer.helpers.buildPriorityList('profile.json') list.should.be.an.instanceOf(Array) - list.should.have.lengthOf(3) + list.should.have.lengthOf(4) list.should.include('profile.json.jade') list.should.include('profile.json.ejs') list.should.include('profile.json.md') - list.should.eql('profile.json.jade, profile.json.ejs, profile.json.md'. split(', ')) + list.should.include('profile.json.hbs') + list.should.eql('profile.json.jade, profile.json.ejs, profile.json.md, profile.json.hbs'. split(', ')) done() }) it('should look for templates when no ext present.', function(done){ var list = polymer.helpers.buildPriorityList('appcache') list.should.be.an.instanceOf(Array) - list.should.have.lengthOf(3) - list.should.eql('appcache.jade, appcache.ejs, appcache.md'.split(', ')) + list.should.have.lengthOf(4) + list.should.eql('appcache.jade, appcache.ejs, appcache.md, appcache.hbs'.split(', ')) done() }) diff --git a/test/templates.js b/test/templates.js index 9bb436a1b..0c441eee0 100644 --- a/test/templates.js +++ b/test/templates.js @@ -25,6 +25,16 @@ describe("templates", function(){ }) }) + describe(".hbs", function(){ + it("should render handlebars file", function(done){ + poly.render("content.hbs", function(error, body){ + should.exist(body) + body.should.include("

Hello! This is Handlebars!

") + done() + }) + }) + }) + describe(".md", function(){ it("should render markdown file", function(done){ poly.render("stuff.md", function(error, body){ From b776fea38c1d4e81ccb7c208ec86aefbb33c617d Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Mon, 24 Mar 2014 10:17:03 -0700 Subject: [PATCH 03/18] Test partials with data, too --- test/fixtures/templates/bio.ejs | 1 + test/fixtures/templates/hbs/partials-with-data.hbs | 2 ++ test/fixtures/templates/hbs/partials.hbs | 3 +++ test/fixtures/templates/index.jade | 2 +- test/fixtures/templates/profile.jade | 2 +- test/templates.js | 12 +++++++++--- 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/templates/hbs/partials-with-data.hbs create mode 100644 test/fixtures/templates/hbs/partials.hbs diff --git a/test/fixtures/templates/bio.ejs b/test/fixtures/templates/bio.ejs index 6d20d47f6..dc81b0237 100644 --- a/test/fixtures/templates/bio.ejs +++ b/test/fixtures/templates/bio.ejs @@ -5,3 +5,4 @@

Hello EJS

<%- partial("stuff.md") %> +<%- partial("profile.jade", { "title": "Brock Whitten" }) %> diff --git a/test/fixtures/templates/hbs/partials-with-data.hbs b/test/fixtures/templates/hbs/partials-with-data.hbs new file mode 100644 index 000000000..ae7f6f5d8 --- /dev/null +++ b/test/fixtures/templates/hbs/partials-with-data.hbs @@ -0,0 +1,2 @@ +

Hello Handlebars

+{{# partial ../profile.jade data="{ "title": "Brock Whitten" }" }} diff --git a/test/fixtures/templates/hbs/partials.hbs b/test/fixtures/templates/hbs/partials.hbs new file mode 100644 index 000000000..448cc763e --- /dev/null +++ b/test/fixtures/templates/hbs/partials.hbs @@ -0,0 +1,3 @@ +

Hello Handlebars

+{{# partial ../profile.jade }} +{{# partial ../stuff.md }} diff --git a/test/fixtures/templates/index.jade b/test/fixtures/templates/index.jade index eee22fc56..19e13809e 100644 --- a/test/fixtures/templates/index.jade +++ b/test/fixtures/templates/index.jade @@ -3,7 +3,7 @@ h2 Hello World -!= partial("profile.jade") +!= partial("profile.jade", { title: "Brock Whitten" }) != partial("stuff.md") h4= place pre diff --git a/test/fixtures/templates/profile.jade b/test/fixtures/templates/profile.jade index 5d358cf2b..95b34cc6f 100644 --- a/test/fixtures/templates/profile.jade +++ b/test/fixtures/templates/profile.jade @@ -1 +1 @@ -h3 Brock Whitten \ No newline at end of file +h3= title diff --git a/test/templates.js b/test/templates.js index 0c441eee0..b86ea37e8 100644 --- a/test/templates.js +++ b/test/templates.js @@ -124,10 +124,16 @@ describe("templates", function(){ poly.render("extend.jade", function(error, body){ should.not.exist(error) should.exist(body) - body.should.include("

Sintaxi

") - body.should.include("

Hello World

") + body.should.include("

hello markdown

") + done() + }) + }) + + it("should pass data into partials", function(done){ + poly.render("hbs/partials-with-data.jade", function(error, body){ + should.not.exist(error) + should.exist(body) body.should.include("

Brock Whitten

") - body.should.include("

Vancouver

") done() }) }) From 964d49e2362265356bc351252b605e8a19722ffb Mon Sep 17 00:00:00 2001 From: Max Kramer Date: Thu, 30 Apr 2015 11:40:55 -0400 Subject: [PATCH 04/18] Bump Handlebars to 3.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86c6fa968..d3f96b532 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "stylus": "0.47.3", "minify": "git://github.com/kennethormandy/minify#v0.3.0", "autoprefixer": "5.1.0", - "handlebars": "^2.0.0" + "handlebars": "^3.0.3" }, "devDependencies": { "mocha": "1.8.2", From 1deee797b83617a3ca1522e82d1e9f1de249b275 Mon Sep 17 00:00:00 2001 From: Max Kramer Date: Thu, 30 Apr 2015 11:43:25 -0400 Subject: [PATCH 05/18] Add partial support for handlebars --- lib/template/processors/hbs.js | 17 ++++++++++ test/fixtures/templates/bio.ejs | 1 - .../templates/hbs/partials-with-data.hbs | 2 +- test/fixtures/templates/hbs/partials.hbs | 3 +- test/templates.js | 33 ++++++++++++++----- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/lib/template/processors/hbs.js b/lib/template/processors/hbs.js index 8222ca82c..3b201027e 100644 --- a/lib/template/processors/hbs.js +++ b/lib/template/processors/hbs.js @@ -3,6 +3,23 @@ var TerraformError = require("../../error").TerraformError module.exports = function(fileContents, options){ + /** + * Provides support to load partials. + * + * @usage without locals + * {{partial '../foo.md'}} + * + * @example with provided locals + * {{partial '../foo.jade' locals='{ "a": "b" }'}} + * + * @returns {Handlebars.SafeString} HTML-safe rendered partial + */ + Handlebars.registerHelper('partial', function(filePath, options) { + var locals = options.hash.locals || {}; + if (typeof locals === 'string') locals = JSON.parse(locals) + return new Handlebars.SafeString(this.partial(filePath, locals)) + }); + return { compile: function(){ return Handlebars.compile(fileContents.toString(), options) diff --git a/test/fixtures/templates/bio.ejs b/test/fixtures/templates/bio.ejs index dc81b0237..6d20d47f6 100644 --- a/test/fixtures/templates/bio.ejs +++ b/test/fixtures/templates/bio.ejs @@ -5,4 +5,3 @@

Hello EJS

<%- partial("stuff.md") %> -<%- partial("profile.jade", { "title": "Brock Whitten" }) %> diff --git a/test/fixtures/templates/hbs/partials-with-data.hbs b/test/fixtures/templates/hbs/partials-with-data.hbs index ae7f6f5d8..f0ec17581 100644 --- a/test/fixtures/templates/hbs/partials-with-data.hbs +++ b/test/fixtures/templates/hbs/partials-with-data.hbs @@ -1,2 +1,2 @@

Hello Handlebars

-{{# partial ../profile.jade data="{ "title": "Brock Whitten" }" }} +{{partial '../profile.jade' locals='{ "title": "Brock Whitten" }' }} diff --git a/test/fixtures/templates/hbs/partials.hbs b/test/fixtures/templates/hbs/partials.hbs index 448cc763e..ef4040556 100644 --- a/test/fixtures/templates/hbs/partials.hbs +++ b/test/fixtures/templates/hbs/partials.hbs @@ -1,3 +1,2 @@

Hello Handlebars

-{{# partial ../profile.jade }} -{{# partial ../stuff.md }} +{{partial '../stuff.md' }} diff --git a/test/templates.js b/test/templates.js index b86ea37e8..0d2ab0032 100644 --- a/test/templates.js +++ b/test/templates.js @@ -33,6 +33,30 @@ describe("templates", function(){ done() }) }) + + it("should render partials", function(done){ + poly.render("hbs/partials.hbs", function(error, body){ + should.not.exist(error) + should.exist(body) + // from main file + body.should.include("

Hello Handlebars

") + // from markdown partial + body.should.include("

hello markdown

") + done() + }) + }) + + it("should pass data into partials", function(done){ + poly.render("hbs/partials-with-data.hbs", function(error, body){ + should.not.exist(error) + should.exist(body) + // from main file + body.should.include("

Hello Handlebars

") + // from jade partial + body.should.include("

Brock Whitten

") + done() + }) + }) }) describe(".md", function(){ @@ -129,15 +153,6 @@ describe("templates", function(){ }) }) - it("should pass data into partials", function(done){ - poly.render("hbs/partials-with-data.jade", function(error, body){ - should.not.exist(error) - should.exist(body) - body.should.include("

Brock Whitten

") - done() - }) - }) - }) }) From 64915d3c7e3f84fcb32174405c29c64a5cdd7d3d Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 13 May 2015 15:30:21 -0700 Subject: [PATCH 06/18] Scopes Jade and Minify, fixes https://github.com/sintaxi/harp/issues/425 --- lib/template/processors/jade.js | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/template/processors/jade.js b/lib/template/processors/jade.js index 2b230c9f7..10c30aa02 100644 --- a/lib/template/processors/jade.js +++ b/lib/template/processors/jade.js @@ -1,4 +1,4 @@ -var jade = require('jade') +var jade = require('@kennethormandy/jade') var TerraformError = require("../../error").TerraformError module.exports = function(fileContents, options){ diff --git a/package.json b/package.json index d74702f8f..a6a8fc11f 100644 --- a/package.json +++ b/package.json @@ -29,15 +29,15 @@ "license": "MIT", "dependencies": { "lru-cache": "2.6.1", - "jade": "git://github.com/harp/jade#v1.9.3-bc.2", + "@kennethormandy/jade": "1.9.3-bc.3", "coffee-script": "1.9.2", "ejs": "1.0.0", "node-sass": "3.0.0-beta.5", "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", - "minify": "git://github.com/kennethormandy/minify#v0.3.0", "autoprefixer": "5.1.0" + "@kennethormandy/minify": "0.3.1", }, "devDependencies": { "mocha": "1.8.2", From 58c366ecaa16b589b399829f05941c73cbe8430c Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 13 May 2015 15:30:28 -0700 Subject: [PATCH 07/18] Updates LRU Cache --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a6a8fc11f..30543d936 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "license": "MIT", "dependencies": { - "lru-cache": "2.6.1", + "lru-cache": "2.6.2", "@kennethormandy/jade": "1.9.3-bc.3", "coffee-script": "1.9.2", "ejs": "1.0.0", From b30538aca1cf58fcf587f1099c3f287bfddb4132 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 13 May 2015 15:30:37 -0700 Subject: [PATCH 08/18] Updates EJS to 2.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 30543d936..a9dee890c 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "lru-cache": "2.6.2", "@kennethormandy/jade": "1.9.3-bc.3", "coffee-script": "1.9.2", - "ejs": "1.0.0", "node-sass": "3.0.0-beta.5", + "ejs": "2.3.1", "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", From c6f3565c3bbe75dac65a3bfca24713ab3d3d9d2d Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 13 May 2015 15:30:57 -0700 Subject: [PATCH 09/18] Updates Node-sass to v3.x proper --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a9dee890c..be76317e2 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "lru-cache": "2.6.2", "@kennethormandy/jade": "1.9.3-bc.3", "coffee-script": "1.9.2", - "node-sass": "3.0.0-beta.5", "ejs": "2.3.1", + "node-sass": "3.1.0", "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", From 0f435428436641af2035723a56acbdbfd4bb32e4 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 13 May 2015 15:31:07 -0700 Subject: [PATCH 10/18] Updates Autoprefixer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index be76317e2..06c887a6b 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", - "autoprefixer": "5.1.0" "@kennethormandy/minify": "0.3.1", + "autoprefixer": "5.1.1" }, "devDependencies": { "mocha": "1.8.2", From 60f2a19d61048cd834d92bb420a66b36701ddc4a Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 15:34:59 -0700 Subject: [PATCH 11/18] Adds Node v0.12.x to test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6e5919de3..7ab627a6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: node_js node_js: - "0.10" + - "0.12" From 05b4420ad1c673070b7ecb560b930994a7edc28f Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 15:35:44 -0700 Subject: [PATCH 12/18] Changes scoped modules to namespaced modules for better npm version compatibility --- lib/javascript/index.js | 2 +- lib/stylesheet/index.js | 2 +- lib/template/index.js | 2 +- lib/template/processors/jade.js | 2 +- package.json | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index d5ec6b6bf..bf5be4e9f 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -1,7 +1,7 @@ var path = require("path") var fs = require("fs") var helpers = require('../helpers') -var minify = require('minify') +var minify = require('harp-minify') /** * Build Processor list for javascripts. diff --git a/lib/stylesheet/index.js b/lib/stylesheet/index.js index 2944eec31..2fc7bf75f 100644 --- a/lib/stylesheet/index.js +++ b/lib/stylesheet/index.js @@ -2,7 +2,7 @@ var path = require("path") var fs = require("fs") var helpers = require('../helpers') var autoprefixer = require('autoprefixer') -var minify = require('minify') +var minify = require('harp-minify') /** * Build Processor list for stylesheets. diff --git a/lib/template/index.js b/lib/template/index.js index 94e1f178d..1011f3531 100644 --- a/lib/template/index.js +++ b/lib/template/index.js @@ -1,7 +1,7 @@ var fs = require("fs") var path = require("path") var helpers = require('../helpers') -var minify = require('minify') +var minify = require('harp-minify') /** diff --git a/lib/template/processors/jade.js b/lib/template/processors/jade.js index 10c30aa02..93c91fd21 100644 --- a/lib/template/processors/jade.js +++ b/lib/template/processors/jade.js @@ -1,4 +1,4 @@ -var jade = require('@kennethormandy/jade') +var jade = require('harp-jade') var TerraformError = require("../../error").TerraformError module.exports = function(fileContents, options){ diff --git a/package.json b/package.json index 06c887a6b..6f55aa4ed 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,14 @@ "license": "MIT", "dependencies": { "lru-cache": "2.6.2", - "@kennethormandy/jade": "1.9.3-bc.3", + "harp-jade": "1.9.3-bc.4", "coffee-script": "1.9.2", "ejs": "2.3.1", "node-sass": "3.1.0", "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", - "@kennethormandy/minify": "0.3.1", + "harp-minify": "0.3.2", "autoprefixer": "5.1.1" }, "devDependencies": { From 1994f19197bf1212cdd0f57354a717d088518ebd Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 15:35:51 -0700 Subject: [PATCH 13/18] Updates LRU Cache --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f55aa4ed..fd1e28bae 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "license": "MIT", "dependencies": { - "lru-cache": "2.6.2", + "lru-cache": "2.6.4", "harp-jade": "1.9.3-bc.4", "coffee-script": "1.9.2", "ejs": "2.3.1", From d6fc4ebb062ea226f46f3bdeb30f7ef0a4151988 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 15:35:56 -0700 Subject: [PATCH 14/18] Updates Node-sass --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd1e28bae..686d2af48 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "harp-jade": "1.9.3-bc.4", "coffee-script": "1.9.2", "ejs": "2.3.1", - "node-sass": "3.1.0", + "node-sass": "3.1.2", "marked": "0.3.3", "less": "2.5.0", "stylus": "0.47.3", From ca28e1817bf8fe1a65ec47df33a9e52cb6148f33 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 15:36:45 -0700 Subject: [PATCH 15/18] Updates LESS --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 686d2af48..961a510fc 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "ejs": "2.3.1", "node-sass": "3.1.2", "marked": "0.3.3", - "less": "2.5.0", + "less": "2.5.1", "stylus": "0.47.3", "harp-minify": "0.3.2", "autoprefixer": "5.1.1" From b98f43fb892f12d08408abcdea684131a9b95067 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 16:16:56 -0700 Subject: [PATCH 16/18] Adds failing test for partial syntax change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per @mckramer’s suggestion https://github.com/sintaxi/terraform/pull/93#issuecomment-98038832 --- test/fixtures/templates/hbs/partials-with-data.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/templates/hbs/partials-with-data.hbs b/test/fixtures/templates/hbs/partials-with-data.hbs index f0ec17581..ed243f646 100644 --- a/test/fixtures/templates/hbs/partials-with-data.hbs +++ b/test/fixtures/templates/hbs/partials-with-data.hbs @@ -1,2 +1,2 @@

Hello Handlebars

-{{partial '../profile.jade' locals='{ "title": "Brock Whitten" }' }} +{{partial '../profile.jade' '{ "title": "Brock Whitten" }' }} From 732327010b79c2e5cdf97614f2bf84de910e876c Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 16:17:12 -0700 Subject: [PATCH 17/18] Adds syntax change for Handlebars partial helper --- lib/template/processors/hbs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/processors/hbs.js b/lib/template/processors/hbs.js index 3b201027e..7e4f35060 100644 --- a/lib/template/processors/hbs.js +++ b/lib/template/processors/hbs.js @@ -15,7 +15,7 @@ module.exports = function(fileContents, options){ * @returns {Handlebars.SafeString} HTML-safe rendered partial */ Handlebars.registerHelper('partial', function(filePath, options) { - var locals = options.hash.locals || {}; + var locals = options || {}; if (typeof locals === 'string') locals = JSON.parse(locals) return new Handlebars.SafeString(this.partial(filePath, locals)) }); From edfc34545e5dc5bf1e2d8496f94079ffd9981aa4 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Thu, 21 May 2015 16:17:31 -0700 Subject: [PATCH 18/18] =?UTF-8?q?Adds=20passing=20tests=20for=20Handlebars?= =?UTF-8?q?=E2=80=99=20use=20of=20global=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fixtures/globals/_data.json | 5 ++++- test/fixtures/globals/blog.hbs | 1 + test/fixtures/globals/contact.hbs | 7 +++++++ test/globals.js | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/globals/blog.hbs create mode 100644 test/fixtures/globals/contact.hbs diff --git a/test/fixtures/globals/_data.json b/test/fixtures/globals/_data.json index 07a394bbc..b9e1b14a0 100644 --- a/test/fixtures/globals/_data.json +++ b/test/fixtures/globals/_data.json @@ -1,5 +1,8 @@ { "about":{ "title": "About Page" + }, + "blog": { + "title": "Blog Page" } -} \ No newline at end of file +} diff --git a/test/fixtures/globals/blog.hbs b/test/fixtures/globals/blog.hbs new file mode 100644 index 000000000..b6515528b --- /dev/null +++ b/test/fixtures/globals/blog.hbs @@ -0,0 +1 @@ +

{{ title }}

diff --git a/test/fixtures/globals/contact.hbs b/test/fixtures/globals/contact.hbs new file mode 100644 index 000000000..225a173e2 --- /dev/null +++ b/test/fixtures/globals/contact.hbs @@ -0,0 +1,7 @@ + + + + {{ title }} + +

{{ name }}

+ diff --git a/test/globals.js b/test/globals.js index 716dc7445..52c6f950d 100644 --- a/test/globals.js +++ b/test/globals.js @@ -6,15 +6,21 @@ describe("data", function(){ describe("valid", function(){ var root = __dirname + "/fixtures/globals" - var poly = polymer.root(root, { "title": "Default Title" }) + var poly = polymer.root(root, { "title": "Default Title", "name": "Annie Person" }) it("should have global available by default", function(done){ poly.render("index.jade", function(error, body){ should.not.exist(error) should.exist(body) body.should.include("Default Title") + }) + poly.render("contact.hbs", function(error, body){ + should.not.exist(error) + should.exist(body) + body.should.include("

Annie Person

") done() }) + }) it("should be able to override globals in the template vars", function(done){ @@ -22,10 +28,15 @@ describe("data", function(){ should.not.exist(error) should.exist(body) body.should.include("About Page") + }) + poly.render("blog.hbs", function(error, body){ + should.not.exist(error) + should.exist(body) + body.should.include("

Blog Page

") done() }) }) }) -}) \ No newline at end of file +})