From c50134beaf2f2e1ebedf2ae4474a2e51cdf020e4 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Sat, 13 Jul 2013 17:34:35 -0700 Subject: [PATCH] spacebars: fewer special identifiers mid-path --- packages/spacebars/spacebars.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/spacebars/spacebars.js b/packages/spacebars/spacebars.js index 9b2763f979..43cac2707c 100644 --- a/packages/spacebars/spacebars.js +++ b/packages/spacebars/spacebars.js @@ -62,12 +62,17 @@ Spacebars.parseStacheTag = function (inputString, pos, options) { return lexer.next(); }; - var scanIdentifier = function () { + var scanIdentifier = function (isFirstInPath) { var tok = scanToken(); - // We don't care about overlap with JS keywords. This code - // won't accept "true", "false", or "null" as identifiers however. - if (tok.type() !== 'IDENTIFIER' && tok.type() !== 'KEYWORD') + // We don't care about overlap with JS keywords, + // but accept "true", "false", and "null" as identifiers + // only if not isFirstInPath. + if (! (tok.type() === 'IDENTIFIER' || + tok.type() === 'KEYWORD' || + ((! isFirstInPath) && (tok.type() === 'BOOLEAN' || + tok.type() === 'NULL')))) { expected('IDENTIFIER'); + } var text = tok.text(); advance(text.length); return text; @@ -106,7 +111,7 @@ Spacebars.parseStacheTag = function (inputString, pos, options) { error("Path can't start with empty string"); segments.push(seg); } else { - var id = scanIdentifier(); + var id = scanIdentifier(! segments.length); if (id === 'this' && ! segments.length) { // initial `this` segments.push('');