diff options
author | Kevin Decker <kpdecker@gmail.com> | 2014-11-29 18:02:12 -0600 |
---|---|---|
committer | Kevin Decker <kpdecker@gmail.com> | 2014-11-29 18:02:12 -0600 |
commit | d4070c36675bfecee290f20bd2d9c23a50e9e00b (patch) | |
tree | 0fdf5adfe0824f0310fe1745effcc1576d060933 /lib/handlebars/compiler/code-gen.js | |
parent | 3a9440f954092558275cd4c05a35ba34bcbfa210 (diff) | |
parent | a655aedb5cf523430b08ada5f8cc4730d1db3e5b (diff) | |
download | handlebars.js-d4070c36675bfecee290f20bd2d9c23a50e9e00b.zip handlebars.js-d4070c36675bfecee290f20bd2d9c23a50e9e00b.tar.gz handlebars.js-d4070c36675bfecee290f20bd2d9c23a50e9e00b.tar.bz2 |
Merge pull request #915 from wycats/ast-update
Ast update
Diffstat (limited to 'lib/handlebars/compiler/code-gen.js')
-rw-r--r-- | lib/handlebars/compiler/code-gen.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/handlebars/compiler/code-gen.js b/lib/handlebars/compiler/code-gen.js index 7d1b4ca..0fddb7c 100644 --- a/lib/handlebars/compiler/code-gen.js +++ b/lib/handlebars/compiler/code-gen.js @@ -79,18 +79,18 @@ CodeGen.prototype = { }, empty: function(loc) { - loc = loc || this.currentLocation || {}; - return new SourceNode(loc.firstLine, loc.firstColumn, this.srcFile); + loc = loc || this.currentLocation || {start:{}}; + return new SourceNode(loc.start.line, loc.start.column, this.srcFile); }, wrap: function(chunk, loc) { if (chunk instanceof SourceNode) { return chunk; } - loc = loc || this.currentLocation || {}; + loc = loc || this.currentLocation || {start:{}}; chunk = castChunk(chunk, this, loc); - return new SourceNode(loc.firstLine, loc.firstColumn, this.srcFile, chunk); + return new SourceNode(loc.start.line, loc.start.column, this.srcFile, chunk); }, functionCall: function(fn, type, params) { @@ -99,7 +99,7 @@ CodeGen.prototype = { }, quotedString: function(str) { - return '"' + str + return '"' + (str + '') .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\n/g, '\\n') @@ -113,7 +113,10 @@ CodeGen.prototype = { for (var key in obj) { if (obj.hasOwnProperty(key)) { - pairs.push([this.quotedString(key), ':', castChunk(obj[key], this)]); + var value = castChunk(obj[key], this); + if (value !== 'undefined') { + pairs.push([this.quotedString(key), ':', value]); + } } } |