From eea708a18d612fcb9e3831c26cda866e7a9f5dbd Mon Sep 17 00:00:00 2001 From: kpdecker Date: Mon, 4 Nov 2013 22:11:53 -0600 Subject: [PATCH] Fix empty string compilation --- spec/regressions.js | 4 ++++ src/handlebars.yy | 1 + 2 files changed, 5 insertions(+) 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