Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: handlebars-lang/handlebars.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.2.0
Choose a base ref
...
head repository: handlebars-lang/handlebars.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.5.3
Choose a head ref

Commits on Sep 20, 2019

  1. fix: use cjs for browser fields

    We should not be using pre-built files for the `browser`.  Resolves #1553
    paulfalgout authored and nknapp committed Sep 20, 2019
    Copy the full SHA
    c55a7be View commit details
  2. integration-tests for various webpack-scenarios

    related to #1553
    
    - registering helpers on an instance retrieved via
      `import`, compiling the template on an instance
       retrieved via `require`
    - using `@roundingwellos/babel-plugin-handlebars-inline-precompile` to load plugins inline
    nknapp committed Sep 20, 2019
    Copy the full SHA
    e47b5ec View commit details
  3. Fix some small typos.

    Maikuolan authored and nknapp committed Sep 20, 2019
    Copy the full SHA
    00b4f2f View commit details
  4. Update release notes

    nknapp committed Sep 20, 2019
    Copy the full SHA
    35bcd44 View commit details
  5. v4.2.1

    nknapp committed Sep 20, 2019
    Copy the full SHA
    fff3e40 View commit details

Commits on Sep 24, 2019

  1. Copy the full SHA
    2078c72 View commit details
  2. adjust compiler revision

    nknapp committed Sep 24, 2019
    Copy the full SHA
    06b7224 View commit details
  3. Update release notes

    nknapp committed Sep 24, 2019
    Copy the full SHA
    bba6560 View commit details
  4. v4.3.0

    nknapp committed Sep 24, 2019
    Copy the full SHA
    a89081d View commit details
  5. Copy the full SHA
    d148d7c View commit details
  6. Copy the full SHA
    93444c5 View commit details
  7. add test for #1560

    nknapp committed Sep 24, 2019
    Copy the full SHA
    64ecb9e View commit details
  8. do not break on precompiled templates from Handlebars >=4.0.0 <4.3.0

    - The version-range above have compiler version 7 and
      precompiled templates expecte the (block)
      HelperMissing-functions in "helpers" and not in "container.hooks".
    - Handlebars now accepts precompiled templates of version 7.
    - If a precompiled template with version 7 is loaded,
      the (block)HelperMissing-functions are kept in "helpers"
    nknapp committed Sep 24, 2019
    Copy the full SHA
    1266838 View commit details
  9. Copy the full SHA
    c2a17c7 View commit details
  10. Copy the full SHA
    e3639e2 View commit details
  11. Update release notes

    nknapp committed Sep 24, 2019
    Copy the full SHA
    2d55790 View commit details
  12. v4.3.1

    nknapp committed Sep 24, 2019
    Copy the full SHA
    050cca0 View commit details

Commits on Sep 26, 2019

  1. Use Object.prototype.propertyIsEnumerable to check for constructors

    - context.propertyIsEnumerable can be replaced
      via __definedGetter__
    - This is a fix specific to counter a known RCE exploit.
      Other fixes will follow.
    
    closes #1563
    nknapp committed Sep 26, 2019
    Copy the full SHA
    213c0bb View commit details
  2. Update release notes

    nknapp committed Sep 26, 2019
    Copy the full SHA
    c5cbeac View commit details
  3. v4.3.2

    nknapp committed Sep 26, 2019
    Copy the full SHA
    2357140 View commit details
  4. Copy the full SHA
    8742bde View commit details

Commits on Sep 27, 2019

  1. Update release notes

    nknapp committed Sep 27, 2019
    Copy the full SHA
    54f7e11 View commit details
  2. v4.3.3

    nknapp committed Sep 27, 2019
    Copy the full SHA
    e473849 View commit details

Commits on Sep 28, 2019

  1. fix: harden "propertyIsEnumerable"-check

    - "container" is an internal object that is most likely
      not accessible through templateing (unlike the proto of "Object", which might be.)
      In order to prevent overriding this method, we
      use "propertyIsEnumerable" from the constructor.
    nknapp committed Sep 28, 2019
    Copy the full SHA
    ff4d827 View commit details
  2. Update release notes

    nknapp committed Sep 28, 2019
    Copy the full SHA
    b250b2d View commit details
  3. v4.3.4

    nknapp committed Sep 28, 2019
    Copy the full SHA
    c958cc8 View commit details

Commits on Sep 29, 2019

  1. Added support for iterable objects in {{#each}} helper (#1557)

    * Added support for iterable object in {{#each}} helper
    Currently {{#each}} helper supports either arrays, or objects,
    however nowadays you can define custom iterable objects by overriding
    a special method called Symbol.iterator, which results in empty result
    being rendered.
    * improved a test for iterables in {{#each}} returning empty result
    * #each helper: using ES5 instead of generator functions in tests
    * #each helper: using ES5 in the helper itself
    antelle authored and nknapp committed Sep 29, 2019
    Copy the full SHA
    cf7545e View commit details
  2. Update release notes

    nknapp committed Sep 29, 2019
    Copy the full SHA
    8f6047c View commit details
  3. v4.4.0

    nknapp committed Sep 29, 2019
    Copy the full SHA
    059b330 View commit details

Commits on Oct 2, 2019

  1. chore: use @knappi/grunt-saucelabs instead of github-dependency

    - mostly because installing dependencies from github takes really
      long in this case.
    nknapp committed Oct 2, 2019
    Copy the full SHA
    c53f340 View commit details
  2. Update release notes

    nknapp committed Oct 2, 2019
    Copy the full SHA
    9cb3165 View commit details
  3. v4.4.1

    nknapp committed Oct 2, 2019
    Copy the full SHA
    b8e769f View commit details
  4. Copy the full SHA
    b7eada0 View commit details
  5. Update release notes

    nknapp committed Oct 2, 2019
    Copy the full SHA
    26d0f7a View commit details
  6. v4.4.2

    nknapp committed Oct 2, 2019
    Copy the full SHA
    b793350 View commit details

Commits on Oct 8, 2019

  1. Copy the full SHA
    0440af2 View commit details
  2. Update release notes

    nknapp committed Oct 8, 2019
    Copy the full SHA
    ba570c4 View commit details
  3. v4.4.3

    nknapp committed Oct 8, 2019
    Copy the full SHA
    2e53fba View commit details
  4. Copy the full SHA
    0b593bf View commit details

Commits on Oct 9, 2019

  1. Copy the full SHA
    feb60f8 View commit details

Commits on Oct 20, 2019

  1. fix: prevent zero length tokens in raw-blocks (#1577)

    This comment ensures that the lexer is not stuck on zero-length tokens, in raw-blocks like {{{{a}}}} {{{{/a}}}}
    nknapp authored Oct 20, 2019
    Copy the full SHA
    aaab609 View commit details
  2. fix: prevent zero length tokens in raw-blocks (#1577)

    This comment ensures that the lexer is not stuck on zero-length tokens, in raw-blocks like {{{{a}}}} {{{{/a}}}}
    nknapp committed Oct 20, 2019
    Copy the full SHA
    f1752fe View commit details
  3. Update release notes

    nknapp committed Oct 20, 2019
    Copy the full SHA
    143ac80 View commit details
  4. v4.4.4

    nknapp committed Oct 20, 2019
    Copy the full SHA
    2ab261e View commit details
  5. fix: non-eager matching raw-block-contents

    In 4.4.4 the block-contents was matched with an eager match, which means
    that with multiple raw-blocks of the same kind, the block was spanned
    over the first ending-tag until the last one.
    This commit replaces this by a non-eager match.
    
    closes #1579
    nknapp committed Oct 20, 2019
    Copy the full SHA
    8d5530e View commit details
  6. fix: non-eager matching raw-block-contents

    In 4.4.4 the block-contents was matched with an eager match, which means
    that with multiple raw-blocks of the same kind, the block was spanned
    over the first ending-tag until the last one.
    This commit replaces this by a non-eager match.
    
    closes #1579
    nknapp committed Oct 20, 2019
    Copy the full SHA
    fd2e5c9 View commit details
  7. Update release notes

    nknapp committed Oct 20, 2019
    Copy the full SHA
    def79fd View commit details
  8. v4.4.5

    nknapp committed Oct 20, 2019
    Copy the full SHA
    8e1cce7 View commit details

Commits on Oct 21, 2019

  1. Merge branch '4.4.x' into 4.x

    nknapp committed Oct 21, 2019
    Copy the full SHA
    a15d01d View commit details

Commits on Oct 27, 2019

  1. fix: add guard to if & unless helpers (#1549)

    fixes #1548
    
    - add a guard to show readable syntax error for if / unless helper
    - prevents against 3 different errors that can be generated by different systax errors
    ErisDS authored and nknapp committed Oct 27, 2019
    Copy the full SHA
    c76ded8 View commit details
Showing with 7,509 additions and 248 deletions.
  1. +8 −19 .eslintrc.js
  2. +2 −1 CONTRIBUTING.md
  3. +1 −1 Gruntfile.js
  4. +5 −6 bench/util/benchwarmer.js
  5. +1 −1 components/bower.json
  6. +1 −1 components/handlebars.js.nuspec
  7. +1 −1 components/package.json
  8. +28 −0 docs/compiler-api.md
  9. +11 −0 integration-testing/webpack-babel-test/.babelrc
  10. +3 −0 integration-testing/webpack-babel-test/.gitignore
  11. +24 −0 integration-testing/webpack-babel-test/package.json
  12. +12 −0 integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js
  13. +5 −0 integration-testing/webpack-babel-test/src/lib/assert.js
  14. +16 −0 integration-testing/webpack-babel-test/test.sh
  15. +32 −0 integration-testing/webpack-babel-test/webpack.config.js
  16. +10 −0 integration-testing/webpack-test/src/handlebars-require-vs-import-test.js
  17. +2 −1 lib/handlebars.js
  18. +5 −3 lib/handlebars/base.js
  19. +10 −2 lib/handlebars/compiler/base.js
  20. +5 −7 lib/handlebars/compiler/code-gen.js
  21. +2 −13 lib/handlebars/compiler/compiler.js
  22. +49 −29 lib/handlebars/compiler/javascript-compiler.js
  23. +1 −1 lib/handlebars/compiler/whitespace-control.js
  24. +13 −2 lib/handlebars/exception.js
  25. +9 −0 lib/handlebars/helpers.js
  26. +19 −11 lib/handlebars/helpers/each.js
  27. +4 −1 lib/handlebars/helpers/if.js
  28. +3 −1 lib/handlebars/helpers/lookup.js
  29. +3 −1 lib/handlebars/helpers/with.js
  30. +40 −31 lib/handlebars/runtime.js
  31. +1 −0 lib/handlebars/utils.js
  32. +359 −69 package-lock.json
  33. +9 −4 package.json
  34. +213 −3 release-notes.md
  35. +15 −5 spec/.eslintrc
  36. +4 −1 spec/amd-runtime.html
  37. +4 −1 spec/amd.html
  38. +105 −0 spec/ast.js
  39. +31 −0 spec/builtins.js
  40. +1 −1 spec/compiler.js
  41. +10 −1 spec/env/browser.js
  42. +102 −3 spec/env/common.js
  43. +9 −0 spec/env/node.js
  44. +9 −0 spec/env/runtime.js
  45. +1 −1 spec/expected/empty.amd.js
  46. +102 −7 spec/helpers.js
  47. +4 −1 spec/index.html
  48. +45 −2 spec/regressions.js
  49. +1 −1 spec/runtime.js
  50. +112 −3 spec/security.js
  51. +19 −0 spec/strict.js
  52. +5 −0 spec/tokenizer.js
  53. +4 −1 spec/umd-runtime.html
  54. +5 −1 spec/umd.html
  55. +1 −1 src/handlebars.l
  56. +1 −1 src/handlebars.yy
  57. +2 −2 tasks/test.js
  58. +37 −5 types/index.d.ts
  59. +134 −1 types/test.ts
  60. +5,839 −0 yarn.lock
27 changes: 8 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
module.exports = {
"extends": "eslint:recommended",
"extends": ["eslint:recommended","plugin:compat/recommended"],
"globals": {
"self": false
},
"env": {
"node": true
},
"ecmaFeatures": {
// Enabling features that can be implemented without polyfills. Want to avoid polyfills at this time.
"arrowFunctions": true,
"blockBindings": true,
"defaultParams": true,
"destructuring": true,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"restParams": true,
"spread": true,
"templateStrings": true
"node": true,
"es6": true
},
"rules": {
// overrides eslint:recommended defaults
@@ -71,6 +57,7 @@ module.exports = {
"no-with": "error",
"radix": "error",
"wrap-iife": "error",
"no-prototype-builtins": "error",


// Variables //
@@ -124,6 +111,8 @@ module.exports = {
"no-var": "warn"
},
"parserOptions": {
"sourceType": "module"
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {}
}
}
};
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ Handlebars utilizes the [release yeoman generator][generator-release] to perform
A full release may be completed with the following:

```
npm ci
yo release
npm publish
yo release:publish components handlebars.js dist/components/
@@ -104,7 +105,7 @@ in those places still point to the latest version

* [The npm-package](https://www.npmjs.com/package/handlebars) (check latest-tag)
* [The bower package](https://github.com/components/handlebars.js) (check the package.json)
* [The AWS S3 Bucket](http://builds.handlebarsjs.com.s3.amazonaws.com/) (check latest-tag)
* [The AWS S3 Bucket](https://s3.amazonaws.com/builds.handlebarsjs.com) (check latest-tag)
* [RubyGems](https://rubygems.org/gems/handlebars-source)

When everything is OK, the handlebars site needs to be updated to point to the new version numbers. The jsfiddle link should be updated to point to the most recent distribution for all instances in our documentation.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-bg-shell');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-saucelabs');
grunt.loadNpmTasks('@knappi/grunt-saucelabs');
grunt.loadNpmTasks('grunt-webpack');

grunt.task.loadTasks('tasks');
11 changes: 5 additions & 6 deletions bench/util/benchwarmer.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ BenchWarmer.prototype = {
});
},
push: function(name, fn) {
if (this.names.indexOf(name) == -1) {
if (this.names.indexOf(name) === -1) {
this.names.push(name);
}

@@ -77,7 +77,7 @@ BenchWarmer.prototype = {

var errors = false, prop, bench;
for (prop in self.errors) {
if (self.errors.hasOwnProperty(prop)
if (Object.prototype.hasOwnProperty.call(self, prop)
&& self.errors[prop].error.message !== 'EWOT') {
errors = true;
break;
@@ -86,9 +86,8 @@ BenchWarmer.prototype = {

if (errors) {
print('\n\nErrors:\n');
for (prop in self.errors) {
if (self.errors.hasOwnProperty(prop)
&& self.errors[prop].error.message !== 'EWOT') {
Object.keys(self.errors).forEach(function(prop) {
if (self.errors[prop].error.message !== 'EWOT') {
bench = self.errors[prop];
print('\n' + bench.name + ':\n');
print(bench.error.message);
@@ -97,7 +96,7 @@ BenchWarmer.prototype = {
}
print('\n');
}
}
});
}

callback();
2 changes: 1 addition & 1 deletion components/bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "handlebars",
"version": "4.2.0",
"version": "4.5.3",
"main": "handlebars.js",
"license": "MIT",
"dependencies": {}
2 changes: 1 addition & 1 deletion components/handlebars.js.nuspec
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<package>
<metadata>
<id>handlebars.js</id>
<version>4.2.0</version>
<version>4.5.3</version>
<authors>handlebars.js Authors</authors>
<licenseUrl>https://github.com/wycats/handlebars.js/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/wycats/handlebars.js/</projectUrl>
2 changes: 1 addition & 1 deletion components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "handlebars",
"version": "4.2.0",
"version": "4.5.3",
"license": "MIT",
"jspm": {
"main": "handlebars",
28 changes: 28 additions & 0 deletions docs/compiler-api.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,34 @@ var ast = Handlebars.parse(myTemplate);
Handlebars.precompile(ast);
```

### Parsing

There are two primary APIs that are used to parse an existing template into the AST:

#### parseWithoutProcessing

`Handlebars.parseWithoutProcessing` is the primary mechanism to turn a raw template string into the Handlebars AST described in this document. No processing is done on the resulting AST which makes this ideal for codemod (for source to source transformation) tooling.

Example:

```js
let ast = Handlebars.parseWithoutProcessing(myTemplate);
```

#### parse

`Handlebars.parse` will parse the template with `parseWithoutProcessing` (see above) then it will update the AST to strip extraneous whitespace. The whitespace stripping functionality handles two distinct situations:

* Removes whitespace around dynamic statements that are on a line by themselves (aka "stand alone")
* Applies "whitespace control" characters (i.e. `~`) by truncating the `ContentStatement` `value` property appropriately (e.g. `\n\n{{~foo}}` would have a `ContentStatement` with a `value` of `''`)

`Handlebars.parse` is used internally by `Handlebars.precompile` and `Handlebars.compile`.

Example:

```js
let ast = Handlebars.parse(myTemplate);
```

### Basic

11 changes: 11 additions & 0 deletions integration-testing/webpack-babel-test/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": [
"@roundingwellos/babel-plugin-handlebars-inline-precompile"
// "istanbul"
],
"presets": [
[
"@babel/preset-env"
]
]
}
3 changes: 3 additions & 0 deletions integration-testing/webpack-babel-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
package-lock.json
24 changes: 24 additions & 0 deletions integration-testing/webpack-babel-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "webpack-babel-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@roundingwellos/babel-plugin-handlebars-inline-precompile": "^3.0.1",
"babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^5.2.0",
"handlebars": "file:../..",
"handlebars-loader": "^1.7.1",
"nyc": "^14.1.1",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7"
},
"scripts": {
"build": "webpack --config webpack.config.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Handlebars from 'handlebars/runtime'
import hbs from 'handlebars-inline-precompile';
import {assertEquals} from "../../webpack-test/src/lib/assert";

Handlebars.registerHelper('loud', function(text) {
return text.toUpperCase();
});

const template = hbs`{{loud name}}`;
const output = template({name: 'yehuda'})

assertEquals(output, 'YEHUDA')
5 changes: 5 additions & 0 deletions integration-testing/webpack-babel-test/src/lib/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function assertEquals(actual, expected) {
if (actual !== expected) {
throw new Error(`Expected "${actual}" to equal "${expected}"`);
}
}
16 changes: 16 additions & 0 deletions integration-testing/webpack-babel-test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

# Cleanup: package-lock and "npm ci" is not working with local dependencies
rm dist package-lock.json -rf
npm install
npm run build

for i in dist/*-test.js ; do
echo "----------------------"
echo "-- Running $i"
echo "----------------------"
node "$i"
echo "Success"
done
32 changes: 32 additions & 0 deletions integration-testing/webpack-babel-test/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require('fs');

const testFiles = fs.readdirSync('src');
const entryPoints = {};
testFiles
.filter(file => file.match(/-test.js$/))
.forEach(file => {
entryPoints[file] = `./src/${file}`;
});

module.exports = {
entry: entryPoints,
output: {
filename: '[name]',
path: __dirname + '/dist'
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { cacheDirectory: false },
}
}
]
},
optimization: {
minimize: false
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as HandlebarsViaImport from 'handlebars';
const HandlebarsViaRequire = require('handlebars');
import {assertEquals} from './lib/assert';

HandlebarsViaImport.registerHelper('loud', function(text) {
return text.toUpperCase();
});

const template = HandlebarsViaRequire.compile('Author: {{loud author}}');
assertEquals(template({author: 'Yehuda'}), 'Author: YEHUDA');
3 changes: 2 additions & 1 deletion lib/handlebars.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import runtime from './handlebars.runtime';

// Compiler imports
import AST from './handlebars/compiler/ast';
import { parser as Parser, parse } from './handlebars/compiler/base';
import { parser as Parser, parse, parseWithoutProcessing } from './handlebars/compiler/base';
import { Compiler, compile, precompile } from './handlebars/compiler/compiler';
import JavaScriptCompiler from './handlebars/compiler/javascript-compiler';
import Visitor from './handlebars/compiler/visitor';
@@ -25,6 +25,7 @@ function create() {
hb.JavaScriptCompiler = JavaScriptCompiler;
hb.Parser = Parser;
hb.parse = parse;
hb.parseWithoutProcessing = parseWithoutProcessing;

return hb;
}
8 changes: 5 additions & 3 deletions lib/handlebars/base.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@ import {registerDefaultHelpers} from './helpers';
import {registerDefaultDecorators} from './decorators';
import logger from './logger';

export const VERSION = '4.2.0';
export const COMPILER_REVISION = 7;
export const VERSION = '4.5.3';
export const COMPILER_REVISION = 8;
export const LAST_COMPATIBLE_COMPILER_REVISION = 7;

export const REVISION_CHANGES = {
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
@@ -14,7 +15,8 @@ export const REVISION_CHANGES = {
4: '== 1.x.x',
5: '== 2.0.0-alpha.x',
6: '>= 2.0.0-beta.1',
7: '>= 4.0.0'
7: '>= 4.0.0 <4.3.0',
8: '>= 4.3.0'
};

const objectType = '[object Object]';
12 changes: 10 additions & 2 deletions lib/handlebars/compiler/base.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ export { parser };
let yy = {};
extend(yy, Helpers);

export function parse(input, options) {
export function parseWithoutProcessing(input, options) {
// Just return if an already-compiled AST was passed in.
if (input.type === 'Program') { return input; }

@@ -19,6 +19,14 @@ export function parse(input, options) {
return new yy.SourceLocation(options && options.srcName, locInfo);
};

let ast = parser.parse(input);

return ast;
}

export function parse(input, options) {
let ast = parseWithoutProcessing(input, options);
let strip = new WhitespaceControl(options);
return strip.accept(parser.parse(input));

return strip.accept(ast);
}
12 changes: 5 additions & 7 deletions lib/handlebars/compiler/code-gen.js
Original file line number Diff line number Diff line change
@@ -125,14 +125,12 @@ CodeGen.prototype = {
objectLiteral: function(obj) {
let pairs = [];

for (let key in obj) {
if (obj.hasOwnProperty(key)) {
let value = castChunk(obj[key], this);
if (value !== 'undefined') {
pairs.push([this.quotedString(key), ':', value]);
}
Object.keys(obj).forEach(key => {
let value = castChunk(obj[key], this);
if (value !== 'undefined') {
pairs.push([this.quotedString(key), ':', value]);
}
}
});

let ret = this.generateList(pairs);
ret.prepend('{');
Loading