Skip to content
Permalink
Browse files

style: reformat all files using prettier

  • Loading branch information
nknapp committed Dec 3, 2019
1 parent 2f0991a commit 3fb331ef40ee1a8308dd83b8e5adbcd798d0adc9
Showing with 5,745 additions and 2,235 deletions.
  1. +79 −38 Gruntfile.js
  2. +11 −6 bench/dist-size.js
  3. +1 −1 bench/index.js
  4. +9 −4 bench/precompile-size.js
  5. +2 −1 bench/templates/arguments.js
  6. +8 −1 bench/templates/array-each.js
  7. +8 −1 bench/templates/array-mustache.js
  8. +3 −3 bench/templates/complex.js
  9. +8 −1 bench/templates/data.js
  10. +9 −1 bench/templates/depth-1.js
  11. +13 −3 bench/templates/depth-2.js
  12. +1 −1 bench/templates/index.js
  13. +4 −1 bench/templates/partial-recursion.js
  14. +10 −2 bench/templates/partial.js
  15. +5 −3 bench/templates/paths.js
  16. +1 −2 bench/templates/variables.js
  17. +50 −26 bench/throughput.js
  18. +48 −21 bench/util/benchwarmer.js
  19. +3 −3 bench/util/template-runner.js
  20. +1 −1 integration-testing/multi-nodejs-test/run-handlebars.js
  21. +5 −5 integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js
  22. +3 −3 integration-testing/webpack-babel-test/src/lib/assert.js
  23. +24 −24 integration-testing/webpack-babel-test/webpack.config.js
  24. +2 −2 integration-testing/webpack-test/src/handlebars-default-import-pre-4.2-test.js
  25. +2 −3 integration-testing/webpack-test/src/handlebars-default-import-test.js
  26. +6 −4 integration-testing/webpack-test/src/handlebars-loader-test.js
  27. +3 −3 integration-testing/webpack-test/src/handlebars-require-vs-import-test.js
  28. +2 −2 integration-testing/webpack-test/src/handlebars-wildcard-import-pre-4.2-test.js
  29. +2 −2 integration-testing/webpack-test/src/handlebars-wildcard-import-test.js
  30. +3 −3 integration-testing/webpack-test/src/lib/assert.js
  31. +12 −14 integration-testing/webpack-test/webpack.config.js
  32. +5 −1 lib/handlebars.js
  33. +13 −7 lib/handlebars/base.js
  34. +10 −6 lib/handlebars/compiler/ast.js
  35. +3 −1 lib/handlebars/compiler/base.js
  36. +21 −16 lib/handlebars/compiler/code-gen.js
  37. +85 −41 lib/handlebars/compiler/compiler.js
  38. +29 −20 lib/handlebars/compiler/helpers.js
  39. +195 −81 lib/handlebars/compiler/javascript-compiler.js
  40. +19 −12 lib/handlebars/compiler/printer.js
  41. +8 −1 lib/handlebars/compiler/visitor.js
  42. +47 −29 lib/handlebars/compiler/whitespace-control.js
  43. +0 −1 lib/handlebars/decorators.js
  44. +1 −1 lib/handlebars/decorators/inline.js
  45. +14 −6 lib/handlebars/exception.js
  46. +2 −2 lib/handlebars/helpers/block-helper-missing.js
  47. +14 −10 lib/handlebars/helpers/each.js
  48. +3 −1 lib/handlebars/helpers/helper-missing.js
  49. +14 −4 lib/handlebars/helpers/if.js
  50. +2 −2 lib/handlebars/helpers/log.js
  51. +4 −1 lib/handlebars/helpers/lookup.js
  52. +7 −3 lib/handlebars/helpers/with.js
  53. +7 −3 lib/handlebars/logger.js
  54. +1 −2 lib/handlebars/no-conflict.js
  55. +138 −42 lib/handlebars/runtime.js
  56. +17 −11 lib/handlebars/utils.js
  57. +117 −75 lib/precompiler.js
  58. +162 −82 spec/ast.js
  59. +442 −139 spec/basic.js
  60. +259 −102 spec/blocks.js
  61. +372 −109 spec/builtins.js
  62. +126 −41 spec/compiler.js
  63. +141 −48 spec/data.js
  64. +5 −3 spec/env/browser.js
  65. +48 −18 spec/env/common.js
  66. +0 −1 spec/env/node.js
  67. +12 −8 spec/env/runner.js
  68. +10 −4 spec/env/runtime.js
  69. +735 −239 spec/helpers.js
  70. +10 −4 spec/javascript-compiler.js
  71. +260 −98 spec/parser.js
  72. +504 −162 spec/partials.js
  73. +185 −92 spec/precompiler.js
  74. +223 −108 spec/regressions.js
  75. +2 −2 spec/require.js
  76. +50 −26 spec/runtime.js
  77. +193 −129 spec/security.js
  78. +15 −9 spec/source-map.js
  79. +26 −14 spec/spec.js
  80. +133 −62 spec/strict.js
  81. +35 −9 spec/subexpressions.js
  82. +395 −48 spec/tokenizer.js
  83. +16 −5 spec/utils.js
  84. +50 −28 spec/visitor.js
  85. +65 −16 spec/whitespace-control.js
  86. +9 −6 tasks/metrics.js
  87. +13 −3 tasks/parser.js
  88. +31 −16 tasks/publish.js
  89. +39 −9 tasks/test.js
  90. +13 −5 tasks/util/git.js
  91. +52 −26 tasks/version.js
@@ -1,28 +1,39 @@
/* eslint-disable no-process-env */
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

clean: ['tmp', 'dist', 'lib/handlebars/compiler/parser.js', 'integration-testing/**/node_modules'],
clean: [
'tmp',
'dist',
'lib/handlebars/compiler/parser.js',
'integration-testing/**/node_modules'
],

copy: {
dist: {
options: {
processContent: function(content) {
return grunt.template.process('/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n')
+ content
+ '\n// @license-end\n';
return (
grunt.template.process(
'/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n'
) +
content +
'\n// @license-end\n'
);
}
},
files: [
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/'}
]
files: [{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/' }]
},
components: {
files: [
{expand: true, cwd: 'components/', src: ['**'], dest: 'dist/components'},
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components'}
{
expand: true,
cwd: 'components/',
src: ['**'],
dest: 'dist/components'
},
{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components' }
]
}
},
@@ -34,12 +45,14 @@ module.exports = function(grunt) {
auxiliaryCommentBefore: 'istanbul ignore next'
},
cjs: {
files: [{
cwd: 'lib/',
expand: true,
src: '**/!(index).js',
dest: 'dist/cjs/'
}]
files: [
{
cwd: 'lib/',
expand: true,
src: '**/!(index).js',
dest: 'dist/cjs/'
}
]
}
},
webpack: {
@@ -72,15 +85,17 @@ module.exports = function(grunt) {
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
},
dist: {
files: [{
cwd: 'dist/',
expand: true,
src: ['handlebars*.js', '!*.min.js'],
dest: 'dist/',
rename: function(dest, src) {
return dest + src.replace(/\.js$/, '.min.js');
files: [
{
cwd: 'dist/',
expand: true,
src: ['handlebars*.js', '!*.min.js'],
dest: 'dist/',
rename: function(dest, src) {
return dest + src.replace(/\.js$/, '.min.js');
}
}
}]
]
}
},

@@ -108,24 +123,39 @@ module.exports = function(grunt) {
detailedError: true,
concurrency: 4,
browsers: [
{browserName: 'chrome'},
{browserName: 'firefox', platform: 'Linux'},
{ browserName: 'chrome' },
{ browserName: 'firefox', platform: 'Linux' },
// {browserName: 'safari', version: 9, platform: 'OS X 10.11'},
// {browserName: 'safari', version: 8, platform: 'OS X 10.10'},
{browserName: 'internet explorer', version: 11, platform: 'Windows 8.1'},
{browserName: 'internet explorer', version: 10, platform: 'Windows 8'}
{
browserName: 'internet explorer',
version: 11,
platform: 'Windows 8.1'
},
{
browserName: 'internet explorer',
version: 10,
platform: 'Windows 8'
}
]
}
},
sanity: {
options: {
build: process.env.TRAVIS_JOB_ID,
urls: ['http://localhost:9999/spec/umd.html?headless=true', 'http://localhost:9999/spec/umd-runtime.html?headless=true'],
urls: [
'http://localhost:9999/spec/umd.html?headless=true',
'http://localhost:9999/spec/umd-runtime.html?headless=true'
],
detailedError: true,
concurrency: 2,
browsers: [
{browserName: 'chrome'},
{browserName: 'internet explorer', version: 10, platform: 'Windows 8'}
{ browserName: 'chrome' },
{
browserName: 'internet explorer',
version: 10,
platform: 'Windows 8'
}
]
}
}
@@ -137,7 +167,6 @@ module.exports = function(grunt) {
bg: false,
fail: true
}

},

watch: {
@@ -167,9 +196,9 @@ module.exports = function(grunt) {
grunt.task.loadTasks('tasks');

this.registerTask(
'build',
'Builds a distributable version of the current project',
['parser', 'node', 'globals']
'build',
'Builds a distributable version of the current project',
['parser', 'node', 'globals']
);

this.registerTask('node', ['babel:cjs']);
@@ -183,13 +212,25 @@ module.exports = function(grunt) {
]);

grunt.registerTask('bench', ['metrics']);
grunt.registerTask('sauce', process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : []);
grunt.registerTask(
'sauce',
process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : []
);
// Requires secret properties (saucelabs-credentials etc.) from .travis.yaml
grunt.registerTask('extensive-tests-and-publish-to-aws', ['default', 'bgShell:integrationTests', 'sauce', 'metrics', 'publish:latest']);
grunt.registerTask('extensive-tests-and-publish-to-aws', [
'default',
'bgShell:integrationTests',
'sauce',
'metrics',
'publish:latest'
]);
grunt.registerTask('on-file-change', ['build', 'concat:tests', 'test']);

// === Primary tasks ===
grunt.registerTask('dev', ['clean', 'connect', 'watch']);
grunt.registerTask('default', ['clean', 'build', 'test', 'release']);
grunt.registerTask('integration-tests', ['default', 'bgShell:integrationTests']);
grunt.registerTask('integration-tests', [
'default',
'bgShell:integrationTests'
]);
};
@@ -1,12 +1,14 @@
var async = require('neo-async'),
fs = require('fs'),
zlib = require('zlib');
fs = require('fs'),
zlib = require('zlib');

module.exports = function(grunt, callback) {
var distFiles = fs.readdirSync('dist'),
distSizes = {};
distSizes = {};

async.each(distFiles, function(file, callback) {
async.each(
distFiles,
function(file, callback) {
var content;
try {
content = fs.readFileSync('dist/' + file);
@@ -32,7 +34,10 @@ module.exports = function(grunt, callback) {
});
},
function() {
grunt.log.writeln('Distribution sizes: ' + JSON.stringify(distSizes, undefined, 2));
grunt.log.writeln(
'Distribution sizes: ' + JSON.stringify(distSizes, undefined, 2)
);
callback([distSizes]);
});
}
);
};
@@ -2,7 +2,7 @@ var fs = require('fs');

var metrics = fs.readdirSync(__dirname);
metrics.forEach(function(metric) {
if (metric === 'index.js' || !(/(.*)\.js$/.test(metric))) {
if (metric === 'index.js' || !/(.*)\.js$/.test(metric)) {
return;
}

@@ -1,5 +1,5 @@
var _ = require('underscore'),
templates = require('./templates');
templates = require('./templates');

module.exports = function(grunt, callback) {
// Deferring to here in case we have a build for parser, etc as part of this grunt exec
@@ -8,12 +8,17 @@ module.exports = function(grunt, callback) {
var templateSizes = {};
_.each(templates, function(info, template) {
var src = info.handlebars,
compiled = Handlebars.precompile(src, {}),
knownHelpers = Handlebars.precompile(src, {knownHelpersOnly: true, knownHelpers: info.helpers});
compiled = Handlebars.precompile(src, {}),
knownHelpers = Handlebars.precompile(src, {
knownHelpersOnly: true,
knownHelpers: info.helpers
});

templateSizes[template] = compiled.length;
templateSizes['knownOnly_' + template] = knownHelpers.length;
});
grunt.log.writeln('Precompiled sizes: ' + JSON.stringify(templateSizes, undefined, 2));
grunt.log.writeln(
'Precompiled sizes: ' + JSON.stringify(templateSizes, undefined, 2)
);
callback([templateSizes]);
};
@@ -8,5 +8,6 @@ module.exports = {
bar: true
},

handlebars: '{{foo person "person" 1 true foo=bar foo="person" foo=1 foo=true}}'
handlebars:
'{{foo person "person" 1 true foo=bar foo="person" foo=1 foo=true}}'
};
@@ -1,5 +1,12 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#each names}}{{name}}{{/each}}',
dust: '{#names}{name}{/names}',
mustache: '{{#names}}{{name}}{{/names}}',
@@ -1,4 +1,11 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#names}}{{name}}{{/names}}'
};
@@ -7,9 +7,9 @@ module.exports = {
},
hasItems: true, // To make things fairer in mustache land due to no `{{if}}` construct on arrays
items: [
{name: 'red', current: true, url: '#Red'},
{name: 'green', current: false, url: '#Green'},
{name: 'blue', current: false, url: '#Blue'}
{ name: 'red', current: true, url: '#Red' },
{ name: 'green', current: false, url: '#Green' },
{ name: 'blue', current: false, url: '#Blue' }
]
},

@@ -1,4 +1,11 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#each names}}{{@index}}{{name}}{{/each}}'
};
@@ -1,5 +1,13 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}], foo: 'bar' },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
],
foo: 'bar'
},
handlebars: '{{#each names}}{{../foo}}{{/each}}',
mustache: '{{#names}}{{foo}}{{/names}}',
eco: '<% for item in @names: %><%= @foo %><% end %>'
@@ -1,6 +1,16 @@
module.exports = {
context: { names: [{bat: 'foo', name: ['Moe']}, {bat: 'foo', name: ['Larry']}, {bat: 'foo', name: ['Curly']}, {bat: 'foo', name: ['Shemp']}], foo: 'bar' },
handlebars: '{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}',
context: {
names: [
{ bat: 'foo', name: ['Moe'] },
{ bat: 'foo', name: ['Larry'] },
{ bat: 'foo', name: ['Curly'] },
{ bat: 'foo', name: ['Shemp'] }
],
foo: 'bar'
},
handlebars:
'{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}',
mustache: '{{#names}}{{#name}}{{bat}}{{foo}}{{/name}}{{/names}}',
eco: '<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>'
eco:
'<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>'
};
@@ -2,7 +2,7 @@ var fs = require('fs');

var templates = fs.readdirSync(__dirname);
templates.forEach(function(template) {
if (template === 'index.js' || !(/(.*)\.js$/.test(template))) {
if (template === 'index.js' || !/(.*)\.js$/.test(template)) {
return;
}
module.exports[RegExp.$1] = require('./' + RegExp.$1);
@@ -1,5 +1,8 @@
module.exports = {
context: { name: '1', kids: [{ name: '1.1', kids: [{name: '1.1.1', kids: []}] }] },
context: {
name: '1',
kids: [{ name: '1.1', kids: [{ name: '1.1.1', kids: [] }] }]
},
partials: {
mustache: { recursion: '{{name}}{{#kids}}{{>recursion}}{{/kids}}' },
handlebars: { recursion: '{{name}}{{#each kids}}{{>recursion}}{{/each}}' }
@@ -1,8 +1,16 @@
module.exports = {
context: { peeps: [{name: 'Moe', count: 15}, {name: 'Larry', count: 5}, {name: 'Curly', count: 1}] },
context: {
peeps: [
{ name: 'Moe', count: 15 },
{ name: 'Larry', count: 5 },
{ name: 'Curly', count: 1 }
]
},
partials: {
mustache: { variables: 'Hello {{name}}! You have {{count}} new messages.' },
handlebars: { variables: 'Hello {{name}}! You have {{count}} new messages.' }
handlebars: {
variables: 'Hello {{name}}! You have {{count}} new messages.'
}
},

handlebars: '{{#each peeps}}{{>variables}}{{/each}}',

0 comments on commit 3fb331e

Please sign in to comment.
You can’t perform that action at this time.