Skip to content

Commit 9b1f9c7

Browse files
committed
Style updates
1 parent 8e868ab commit 9b1f9c7

29 files changed

+154
-124
lines changed

Gruntfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = function(grunt) {
99
},
1010
files: [
1111
'*.js',
12+
'bench/**/*.js',
13+
'tasks/**/*.js',
1214
'lib/**/!(*.min|parser).js',
1315
'spec/**/!(*.amd|json2|require).js'
1416
]

bench/.eslintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"globals": {
3+
"require": true
4+
},
5+
"rules": {
6+
// Disabling for tests, for now.
7+
"no-path-concat": 0,
8+
9+
"no-var": 0,
10+
"no-shadow": 0,
11+
"handle-callback-err": 0,
12+
"no-console": 0
13+
}
14+
}

bench/dist-size.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var _ = require('underscore'),
2-
async = require('async'),
1+
var async = require('async'),
32
fs = require('fs'),
43
zlib = require('zlib');
54

bench/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var fs = require('fs');
22

33
var metrics = fs.readdirSync(__dirname);
44
metrics.forEach(function(metric) {
5-
if (metric === 'index.js' || !/(.*)\.js$/.test(metric)) {
5+
if (metric === 'index.js' || !(/(.*)\.js$/.test(metric))) {
66
return;
77
}
88

bench/templates/arguments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
helpers: {
3-
foo: function(options) {
3+
foo: function() {
44
return '';
55
}
66
},

bench/templates/array-each.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
3-
handlebars: "{{#each names}}{{name}}{{/each}}",
4-
dust: "{#names}{name}{/names}",
5-
mustache: "{{#names}}{{name}}{{/names}}",
6-
eco: "<% for item in @names: %><%= item.name %><% end %>"
2+
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
3+
handlebars: '{{#each names}}{{name}}{{/each}}',
4+
dust: '{#names}{name}{/names}',
5+
mustache: '{{#names}}{{name}}{{/names}}',
6+
eco: '<% for item in @names: %><%= item.name %><% end %>'
77
};

bench/templates/array-mustache.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
3-
handlebars: "{{#names}}{{name}}{{/names}}"
4-
}
2+
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
3+
handlebars: '{{#names}}{{name}}{{/names}}'
4+
};

bench/templates/complex.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ var fs = require('fs');
33
module.exports = {
44
context: {
55
header: function() {
6-
return "Colors";
6+
return 'Colors';
77
},
88
hasItems: true, // To make things fairer in mustache land due to no `{{if}}` construct on arrays
99
items: [
10-
{name: "red", current: true, url: "#Red"},
11-
{name: "green", current: false, url: "#Green"},
12-
{name: "blue", current: false, url: "#Blue"}
10+
{name: 'red', current: true, url: '#Red'},
11+
{name: 'green', current: false, url: '#Green'},
12+
{name: 'blue', current: false, url: '#Blue'}
1313
]
1414
},
1515

bench/templates/data.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
3-
handlebars: "{{#each names}}{{@index}}{{name}}{{/each}}"
4-
}
2+
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
3+
handlebars: '{{#each names}}{{@index}}{{name}}{{/each}}'
4+
};

bench/templates/depth-1.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}], foo: 'bar' },
3-
handlebars: "{{#each names}}{{../foo}}{{/each}}",
4-
mustache: "{{#names}}{{foo}}{{/names}}",
5-
eco: "<% for item in @names: %><%= @foo %><% end %>"
2+
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}], foo: 'bar' },
3+
handlebars: '{{#each names}}{{../foo}}{{/each}}',
4+
mustache: '{{#names}}{{foo}}{{/names}}',
5+
eco: '<% for item in @names: %><%= @foo %><% end %>'
66
};

bench/templates/depth-2.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
context: { names: [{bat: 'foo', name: ["Moe"]}, {bat: 'foo', name: ["Larry"]}, {bat: 'foo', name: ["Curly"]}, {bat: 'foo', name: ["Shemp"]}], foo: 'bar' },
3-
handlebars: "{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}",
4-
mustache: "{{#names}}{{#name}}{{bat}}{{foo}}{{/name}}{{/names}}",
5-
eco: "<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>"
2+
context: { names: [{bat: 'foo', name: ['Moe']}, {bat: 'foo', name: ['Larry']}, {bat: 'foo', name: ['Curly']}, {bat: 'foo', name: ['Shemp']}], foo: 'bar' },
3+
handlebars: '{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}',
4+
mustache: '{{#names}}{{#name}}{{bat}}{{foo}}{{/name}}{{/names}}',
5+
eco: '<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>'
66
};

bench/templates/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var fs = require('fs');
22

33
var templates = fs.readdirSync(__dirname);
44
templates.forEach(function(template) {
5-
if (template === 'index.js' || !/(.*)\.js$/.test(template)) {
5+
if (template === 'index.js' || !(/(.*)\.js$/.test(template))) {
66
return;
77
}
88
module.exports[RegExp.$1] = require('./' + RegExp.$1);

bench/templates/object-mustache.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
context: { person: { name: "Larry", age: 45 } },
3-
handlebars: "{{#person}}{{name}}{{age}}{{/person}}"
2+
context: { person: { name: 'Larry', age: 45 } },
3+
handlebars: '{{#person}}{{name}}{{age}}{{/person}}'
44
};

bench/templates/object.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
context: { person: { name: "Larry", age: 45 } },
3-
handlebars: "{{#with person}}{{name}}{{age}}{{/with}}",
4-
dust: "{#person}{name}{age}{/person}",
5-
eco: "<%= @person.name %><%= @person.age %>",
6-
mustache: "{{#person}}{{name}}{{age}}{{/person}}"
2+
context: { person: { name: 'Larry', age: 45 } },
3+
handlebars: '{{#with person}}{{name}}{{age}}{{/with}}',
4+
dust: '{#person}{name}{age}{/person}',
5+
eco: '<%= @person.name %><%= @person.age %>',
6+
mustache: '{{#person}}{{name}}{{age}}{{/person}}'
77
};

bench/templates/partial-recursion.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = {
22
context: { name: '1', kids: [{ name: '1.1', kids: [{name: '1.1.1', kids: []}] }] },
33
partials: {
4-
mustache: { recursion: "{{name}}{{#kids}}{{>recursion}}{{/kids}}" },
5-
handlebars: { recursion: "{{name}}{{#each kids}}{{>recursion}}{{/each}}" }
4+
mustache: { recursion: '{{name}}{{#kids}}{{>recursion}}{{/kids}}' },
5+
handlebars: { recursion: '{{name}}{{#each kids}}{{>recursion}}{{/each}}' }
66
},
7-
handlebars: "{{name}}{{#each kids}}{{>recursion}}{{/each}}",
8-
dust: "{name}{#kids}{>recursion:./}{/kids}",
9-
mustache: "{{name}}{{#kids}}{{>recursion}}{{/kids}}"
7+
handlebars: '{{name}}{{#each kids}}{{>recursion}}{{/each}}',
8+
dust: '{name}{#kids}{>recursion:./}{/kids}',
9+
mustache: '{{name}}{{#kids}}{{>recursion}}{{/kids}}'
1010
};

bench/templates/partial.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
2-
context: { peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 1}] },
2+
context: { peeps: [{name: 'Moe', count: 15}, {name: 'Larry', count: 5}, {name: 'Curly', count: 1}] },
33
partials: {
4-
mustache: { variables: "Hello {{name}}! You have {{count}} new messages." },
5-
handlebars: { variables: "Hello {{name}}! You have {{count}} new messages." }
4+
mustache: { variables: 'Hello {{name}}! You have {{count}} new messages.' },
5+
handlebars: { variables: 'Hello {{name}}! You have {{count}} new messages.' }
66
},
77

8-
handlebars: "{{#each peeps}}{{>variables}}{{/each}}",
9-
dust: "{#peeps}{>variables/}{/peeps}",
10-
mustache: "{{#peeps}}{{>variables}}{{/peeps}}"
8+
handlebars: '{{#each peeps}}{{>variables}}{{/each}}',
9+
dust: '{#peeps}{>variables/}{/peeps}',
10+
mustache: '{{#peeps}}{{>variables}}{{/peeps}}'
1111
};

bench/templates/paths.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
context: { person: { name: {bar: {baz: "Larry"}}, age: 45 } },
3-
handlebars: "{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}",
4-
dust: "{person.name.bar.baz}{person.age}{person.foo}{animal.age}",
5-
eco: "<%= @person.name.bar.baz %><%= @person.age %><%= @person.foo %><% if @animal: %><%= @animal.age %><% end %>",
6-
mustache: "{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}"
2+
context: { person: { name: {bar: {baz: 'Larry'}}, age: 45 } },
3+
handlebars: '{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}',
4+
dust: '{person.name.bar.baz}{person.age}{person.foo}{animal.age}',
5+
eco: '<%= @person.name.bar.baz %><%= @person.age %><%= @person.foo %><% if @animal: %><%= @animal.age %><% end %>',
6+
mustache: '{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}'
77
};

bench/templates/string.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
context: {},
3-
handlebars: "Hello world",
4-
dust: "Hello world",
5-
mustache: "Hello world",
6-
eco: "Hello world"
3+
handlebars: 'Hello world',
4+
dust: 'Hello world',
5+
mustache: 'Hello world',
6+
eco: 'Hello world'
77
};

bench/templates/subexpression.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ module.exports = {
44
return 'foo ' + value;
55
},
66
header: function() {
7-
return "Colors";
7+
return 'Colors';
88
}
99
},
10-
handlebars: "{{echo (header)}}",
11-
eco: "<%= @echo(@header()) %>"
10+
handlebars: '{{echo (header)}}',
11+
eco: '<%= @echo(@header()) %>'
1212
};
1313

1414
module.exports.context = module.exports.helpers;

bench/templates/variables.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
2-
context: {name: "Mick", count: 30},
3-
handlebars: "Hello {{name}}! You have {{count}} new messages.",
4-
dust: "Hello {name}! You have {count} new messages.",
5-
mustache: "Hello {{name}}! You have {{count}} new messages.",
6-
eco: "Hello <%= @name %>! You have <%= @count %> new messages."
2+
context: {name: 'Mick', count: 30},
3+
handlebars: 'Hello {{name}}! You have {{count}} new messages.',
4+
dust: 'Hello {name}! You have {count} new messages.',
5+
mustache: 'Hello {{name}}! You have {{count}} new messages.',
6+
eco: 'Hello <%= @name %>! You have <%= @count %> new messages.'
77
};
88

bench/throughput.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
var _ = require('underscore'),
22
runner = require('./util/template-runner'),
3-
templates = require('./templates'),
43

54
eco, dust, Handlebars, Mustache, eco;
65

76
try {
8-
dust = require("dustjs-linkedin");
7+
dust = require('dustjs-linkedin');
98
} catch (err) { /* NOP */ }
109

1110
try {
12-
Mustache = require("mustache");
11+
Mustache = require('mustache');
1312
} catch (err) { /* NOP */ }
1413

1514
try {
16-
eco = require("eco");
15+
eco = require('eco');
1716
} catch (err) { /* NOP */ }
1817

1918
function error() {
20-
throw new Error("EWOT");
19+
throw new Error('EWOT');
2120
}
2221

2322
function makeSuite(bench, name, template, handlebarsOnly) {
@@ -34,19 +33,19 @@ function makeSuite(bench, name, template, handlebarsOnly) {
3433
mustacheOut;
3534

3635
var handlebar = Handlebars.compile(template.handlebars, {data: false}),
37-
compat = Handlebars.compile(template.handlebars, {data: false, compat: true}),
36+
compat = Handlebars.compile(template.handlebars, {data: false, compat: true}),
3837
options = {helpers: template.helpers};
39-
_.each(template.partials && template.partials.handlebars, function(partial, name) {
38+
_.each(template.partials && template.partials.handlebars, function(partial) {
4039
Handlebars.registerPartial(name, Handlebars.compile(partial, {data: false}));
4140
});
4241

4342
handlebarsOut = handlebar(context, options);
44-
bench("handlebars", function() {
43+
bench('handlebars', function() {
4544
handlebar(context, options);
4645
});
4746

4847
compatOut = compat(context, options);
49-
bench("compat", function() {
48+
bench('compat', function() {
5049
compat(context, options);
5150
});
5251

@@ -61,8 +60,8 @@ function makeSuite(bench, name, template, handlebarsOnly) {
6160

6261
dust.render(templateName, context, function(err, out) { dustOut = out; });
6362

64-
bench("dust", function() {
65-
dust.render(templateName, context, function(err, out) { });
63+
bench('dust', function() {
64+
dust.render(templateName, context, function() {});
6665
});
6766
} else {
6867
bench('dust', error);
@@ -75,11 +74,11 @@ function makeSuite(bench, name, template, handlebarsOnly) {
7574

7675
ecoOut = ecoTemplate(context);
7776

78-
bench("eco", function() {
77+
bench('eco', function() {
7978
ecoTemplate(context);
8079
});
8180
} else {
82-
bench("eco", error);
81+
bench('eco', error);
8382
}
8483
}
8584

@@ -90,11 +89,11 @@ function makeSuite(bench, name, template, handlebarsOnly) {
9089
if (mustacheSource) {
9190
mustacheOut = Mustache.to_html(mustacheSource, context, mustachePartials);
9291

93-
bench("mustache", function() {
92+
bench('mustache', function() {
9493
Mustache.to_html(mustacheSource, context, mustachePartials);
9594
});
9695
} else {
97-
bench("mustache", error);
96+
bench('mustache', error);
9897
}
9998
}
10099

0 commit comments

Comments
 (0)