diff --git a/Gruntfile.js b/Gruntfile.js index 4fe9b0531..3a15813dd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -147,17 +147,6 @@ module.exports = function(grunt) { // traceur exec issues grunt.util.spawn({grunt: true, args: ['--stack', 'packager'], opts: {stdio: 'inherit'}}, this.async()); }); - grunt.registerTask('test', function() { - var done = this.async(); - - var runner = childProcess.fork('./spec/env/runner', [], {stdio: 'inherit'}); - runner.on('close', function(code) { - if (code != 0) { - grunt.fatal(code + ' tests failed'); - } - done(); - }); - }); grunt.registerTask('bench', ['metrics']); grunt.registerTask('default', ['build', 'test', 'release']); diff --git a/bin/handlebars b/bin/handlebars index d51df92de..0e0cbc27f 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -127,7 +127,7 @@ extension = new RegExp('\\.' + extension + '$'); var output = []; if (!argv.simple) { if (argv.amd) { - output.push('define([\'' + argv.handlebarPath + 'handlebars\'], function(Handlebars) {\n Handlebars = Handlebars["default"];'); + output.push('define([\'' + argv.handlebarPath + 'handlebars.runtime\'], function(Handlebars) {\n Handlebars = Handlebars["default"];'); } else if (argv.commonjs) { output.push('var Handlebars = require("' + argv.commonjs + '");'); } else { diff --git a/components/bower.json b/components/bower.json index 2631b5f3f..cd3c600cf 100644 --- a/components/bower.json +++ b/components/bower.json @@ -1,6 +1,6 @@ { "name": "handlebars", - "version": "1.1.1", + "version": "1.1.2", "main": "handlebars.js", "dependencies": {} } diff --git a/components/handlebars.js.nuspec b/components/handlebars.js.nuspec index 0e8a1daf8..a756b7040 100644 --- a/components/handlebars.js.nuspec +++ b/components/handlebars.js.nuspec @@ -2,7 +2,7 @@ handlebars.js - 1.1.1 + 1.1.2 handlebars.js Authors https://github.com/wycats/handlebars.js/blob/master/LICENSE https://github.com/wycats/handlebars.js/ diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index f9d8aa934..56eb016a1 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -2,7 +2,7 @@ module Utils from "./utils"; import Exception from "./exception"; -export var VERSION = "1.1.1"; +export var VERSION = "1.1.2"; export var COMPILER_REVISION = 4; export var REVISION_CHANGES = { @@ -12,25 +12,11 @@ export var REVISION_CHANGES = { 4: '>= 1.0.0' }; -var toString = Object.prototype.toString, +var isArray = Utils.isArray, + isFunction = Utils.isFunction, + toString = Utils.toString, objectType = '[object Object]'; -// Sourced from lodash -// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt -var isFunction = function(value) { - return typeof value === 'function'; -}; -// fallback for older versions of Chrome and Safari -if (isFunction(/x/)) { - isFunction = function(value) { - return typeof value === 'function' && toString.call(value) === '[object Function]'; - }; -} - -function isArray(value) { - return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; -} - export function HandlebarsEnvironment(helpers, partials) { this.helpers = helpers || {}; this.partials = partials || {}; diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index 998c9ca6b..65e91f905 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -1,7 +1,5 @@ import SafeString from "./safe-string"; -var isArray = Array.isArray; - var escape = { "&": "&", "<": "<", @@ -26,6 +24,26 @@ export function extend(obj, value) { } } +export var toString = Object.prototype.toString; + +// Sourced from lodash +// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt +var isFunction = function(value) { + return typeof value === 'function'; +}; +// fallback for older versions of Chrome and Safari +if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; +} +export var isFunction; + +export var isArray = Array.isArray || function(value) { + return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; +}; + + export function escapeExpression(string) { // don't escape SafeStrings, since they're already safe if (string instanceof SafeString) { diff --git a/package.json b/package.json index d22c8c11b..77b9fcbbb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "handlebars", "barename": "handlebars", - "version": "1.1.1", + "version": "1.1.2", "description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration", "homepage": "http://www.handlebarsjs.com/", "keywords": [ @@ -46,7 +46,8 @@ "mustache": "~0.7.2", "semver": "~2.1.0", "should": "~1.2.2", - "underscore": "~1.5.1" + "underscore": "~1.5.1", + "grunt-cli": "~0.1.10" }, "main": "lib/index.js", "bin": { diff --git a/release-notes.md b/release-notes.md index 58b3ead85..6464976c6 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,7 +2,17 @@ ## Development -[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.1...master) +[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.2...master) + +## v1.1.2 - November 5th, 2013 + +- [#645](https://github.com/wycats/handlebars.js/issues/645) - 1.1.1 fails under IE8 ([@kpdecker](https://api.github.com/users/kpdecker)) +- [#644](https://github.com/wycats/handlebars.js/issues/644) - Using precompiled templates (AMD mode) with handlebars.runtime 1.1.1 ([@fddima](https://api.github.com/users/fddima)) + +- Add simple binary utility tests - 96a45a4 +- Fix empty string compilation - eea708a + +[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.1...v1.1.2) ## v1.1.1 - November 4th, 2013 diff --git a/spec/artifacts/empty.handlebars b/spec/artifacts/empty.handlebars new file mode 100644 index 000000000..e69de29bb diff --git a/spec/expected/empty.amd.js b/spec/expected/empty.amd.js new file mode 100644 index 000000000..657970cd0 --- /dev/null +++ b/spec/expected/empty.amd.js @@ -0,0 +1,11 @@ +define(['handlebars.runtime'], function(Handlebars) { + Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +return templates['empty'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; +helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = ""; + + + return buffer; + }); +}); diff --git a/spec/regressions.js b/spec/regressions.js index 44bde81b6..eec5a490b 100644 --- a/spec/regressions.js +++ b/spec/regressions.js @@ -115,5 +115,9 @@ describe('Regressions', function() { it("can pass through an already-compiled AST via compile/precompile", function() { equal(Handlebars.compile(new Handlebars.AST.ProgramNode([ new Handlebars.AST.ContentNode("Hello")]))(), 'Hello'); }); + + it("can pass through an empty string", function() { + equal(Handlebars.compile('')(), ''); + }); } }); diff --git a/src/handlebars.yy b/src/handlebars.yy index 0afd2cbbc..71a857546 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -17,6 +17,7 @@ function stripFlags(open, close) { root : statements EOF { return new yy.ProgramNode($1); } + | EOF { return new yy.ProgramNode([]); } ; program diff --git a/tasks/test.js b/tasks/test.js new file mode 100644 index 000000000..cd5f00e80 --- /dev/null +++ b/tasks/test.js @@ -0,0 +1,32 @@ +var childProcess = require('child_process'), + fs = require('fs'); + +module.exports = function(grunt) { + grunt.registerTask('test:bin', function() { + var done = this.async(); + + childProcess.exec('./bin/handlebars -a spec/artifacts/empty.handlebars', function(err, stdout) { + if (err) { + throw err; + } + + if (stdout.toString() !== fs.readFileSync('./spec/expected/empty.amd.js').toString()) { + throw new Error('Expected binary output differed'); + } + + done(); + }); + }); + grunt.registerTask('test:mocha', function() { + var done = this.async(); + + var runner = childProcess.fork('./spec/env/runner', [], {stdio: 'inherit'}); + runner.on('close', function(code) { + if (code != 0) { + grunt.fatal(code + ' tests failed'); + } + done(); + }); + }); + grunt.registerTask('test', ['test:bin', 'test:mocha']); +};