Skip to content

Commit

Permalink
Style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdecker committed Aug 3, 2015
1 parent 8e868ab commit 9b1f9c7
Show file tree
Hide file tree
Showing 29 changed files with 154 additions and 124 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = function(grunt) {
},
files: [
'*.js',
'bench/**/*.js',
'tasks/**/*.js',
'lib/**/!(*.min|parser).js',
'spec/**/!(*.amd|json2|require).js'
]
Expand Down
14 changes: 14 additions & 0 deletions bench/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"globals": {
"require": true
},
"rules": {
// Disabling for tests, for now.
"no-path-concat": 0,

"no-var": 0,
"no-shadow": 0,
"handle-callback-err": 0,
"no-console": 0
}
}
3 changes: 1 addition & 2 deletions bench/dist-size.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var _ = require('underscore'),
async = require('async'),
var async = require('async'),
fs = require('fs'),
zlib = require('zlib');

Expand Down
2 changes: 1 addition & 1 deletion bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion bench/templates/arguments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
helpers: {
foo: function(options) {
foo: function() {
return '';
}
},
Expand Down
10 changes: 5 additions & 5 deletions bench/templates/array-each.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
handlebars: "{{#each names}}{{name}}{{/each}}",
dust: "{#names}{name}{/names}",
mustache: "{{#names}}{{name}}{{/names}}",
eco: "<% for item in @names: %><%= item.name %><% end %>"
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
handlebars: '{{#each names}}{{name}}{{/each}}',
dust: '{#names}{name}{/names}',
mustache: '{{#names}}{{name}}{{/names}}',
eco: '<% for item in @names: %><%= item.name %><% end %>'
};
6 changes: 3 additions & 3 deletions bench/templates/array-mustache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
handlebars: "{{#names}}{{name}}{{/names}}"
}
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
handlebars: '{{#names}}{{name}}{{/names}}'
};
8 changes: 4 additions & 4 deletions bench/templates/complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ var fs = require('fs');
module.exports = {
context: {
header: function() {
return "Colors";
return 'Colors';
},
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'}
]
},

Expand Down
6 changes: 3 additions & 3 deletions bench/templates/data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] },
handlebars: "{{#each names}}{{@index}}{{name}}{{/each}}"
}
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
handlebars: '{{#each names}}{{@index}}{{name}}{{/each}}'
};
8 changes: 4 additions & 4 deletions bench/templates/depth-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
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 %>"
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 %>'
};
8 changes: 4 additions & 4 deletions bench/templates/depth-2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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}}",
mustache: "{{#names}}{{#name}}{{bat}}{{foo}}{{/name}}{{/names}}",
eco: "<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>"
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 %>'
};
2 changes: 1 addition & 1 deletion bench/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions bench/templates/object-mustache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
context: { person: { name: "Larry", age: 45 } },
handlebars: "{{#person}}{{name}}{{age}}{{/person}}"
context: { person: { name: 'Larry', age: 45 } },
handlebars: '{{#person}}{{name}}{{age}}{{/person}}'
};
10 changes: 5 additions & 5 deletions bench/templates/object.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
context: { person: { name: "Larry", age: 45 } },
handlebars: "{{#with person}}{{name}}{{age}}{{/with}}",
dust: "{#person}{name}{age}{/person}",
eco: "<%= @person.name %><%= @person.age %>",
mustache: "{{#person}}{{name}}{{age}}{{/person}}"
context: { person: { name: 'Larry', age: 45 } },
handlebars: '{{#with person}}{{name}}{{age}}{{/with}}',
dust: '{#person}{name}{age}{/person}',
eco: '<%= @person.name %><%= @person.age %>',
mustache: '{{#person}}{{name}}{{age}}{{/person}}'
};
10 changes: 5 additions & 5 deletions bench/templates/partial-recursion.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
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}}" }
mustache: { recursion: '{{name}}{{#kids}}{{>recursion}}{{/kids}}' },
handlebars: { recursion: '{{name}}{{#each kids}}{{>recursion}}{{/each}}' }
},
handlebars: "{{name}}{{#each kids}}{{>recursion}}{{/each}}",
dust: "{name}{#kids}{>recursion:./}{/kids}",
mustache: "{{name}}{{#kids}}{{>recursion}}{{/kids}}"
handlebars: '{{name}}{{#each kids}}{{>recursion}}{{/each}}',
dust: '{name}{#kids}{>recursion:./}{/kids}',
mustache: '{{name}}{{#kids}}{{>recursion}}{{/kids}}'
};
12 changes: 6 additions & 6 deletions bench/templates/partial.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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." }
mustache: { variables: 'Hello {{name}}! You have {{count}} new messages.' },
handlebars: { variables: 'Hello {{name}}! You have {{count}} new messages.' }
},

handlebars: "{{#each peeps}}{{>variables}}{{/each}}",
dust: "{#peeps}{>variables/}{/peeps}",
mustache: "{{#peeps}}{{>variables}}{{/peeps}}"
handlebars: '{{#each peeps}}{{>variables}}{{/each}}',
dust: '{#peeps}{>variables/}{/peeps}',
mustache: '{{#peeps}}{{>variables}}{{/peeps}}'
};
10 changes: 5 additions & 5 deletions bench/templates/paths.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
context: { person: { name: {bar: {baz: "Larry"}}, age: 45 } },
handlebars: "{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}",
dust: "{person.name.bar.baz}{person.age}{person.foo}{animal.age}",
eco: "<%= @person.name.bar.baz %><%= @person.age %><%= @person.foo %><% if @animal: %><%= @animal.age %><% end %>",
mustache: "{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}"
context: { person: { name: {bar: {baz: 'Larry'}}, age: 45 } },
handlebars: '{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}',
dust: '{person.name.bar.baz}{person.age}{person.foo}{animal.age}',
eco: '<%= @person.name.bar.baz %><%= @person.age %><%= @person.foo %><% if @animal: %><%= @animal.age %><% end %>',
mustache: '{{person.name.bar.baz}}{{person.age}}{{person.foo}}{{animal.age}}'
};
8 changes: 4 additions & 4 deletions bench/templates/string.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
context: {},
handlebars: "Hello world",
dust: "Hello world",
mustache: "Hello world",
eco: "Hello world"
handlebars: 'Hello world',
dust: 'Hello world',
mustache: 'Hello world',
eco: 'Hello world'
};
6 changes: 3 additions & 3 deletions bench/templates/subexpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module.exports = {
return 'foo ' + value;
},
header: function() {
return "Colors";
return 'Colors';
}
},
handlebars: "{{echo (header)}}",
eco: "<%= @echo(@header()) %>"
handlebars: '{{echo (header)}}',
eco: '<%= @echo(@header()) %>'
};

module.exports.context = module.exports.helpers;
10 changes: 5 additions & 5 deletions bench/templates/variables.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
context: {name: "Mick", count: 30},
handlebars: "Hello {{name}}! You have {{count}} new messages.",
dust: "Hello {name}! You have {count} new messages.",
mustache: "Hello {{name}}! You have {{count}} new messages.",
eco: "Hello <%= @name %>! You have <%= @count %> new messages."
context: {name: 'Mick', count: 30},
handlebars: 'Hello {{name}}! You have {{count}} new messages.',
dust: 'Hello {name}! You have {count} new messages.',
mustache: 'Hello {{name}}! You have {{count}} new messages.',
eco: 'Hello <%= @name %>! You have <%= @count %> new messages.'
};

29 changes: 14 additions & 15 deletions bench/throughput.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
var _ = require('underscore'),
runner = require('./util/template-runner'),
templates = require('./templates'),

eco, dust, Handlebars, Mustache, eco;

try {
dust = require("dustjs-linkedin");
dust = require('dustjs-linkedin');
} catch (err) { /* NOP */ }

try {
Mustache = require("mustache");
Mustache = require('mustache');
} catch (err) { /* NOP */ }

try {
eco = require("eco");
eco = require('eco');
} catch (err) { /* NOP */ }

function error() {
throw new Error("EWOT");
throw new Error('EWOT');
}

function makeSuite(bench, name, template, handlebarsOnly) {
Expand All @@ -34,19 +33,19 @@ function makeSuite(bench, name, template, handlebarsOnly) {
mustacheOut;

var handlebar = Handlebars.compile(template.handlebars, {data: false}),
compat = Handlebars.compile(template.handlebars, {data: false, compat: true}),
compat = Handlebars.compile(template.handlebars, {data: false, compat: true}),
options = {helpers: template.helpers};
_.each(template.partials && template.partials.handlebars, function(partial, name) {
_.each(template.partials && template.partials.handlebars, function(partial) {
Handlebars.registerPartial(name, Handlebars.compile(partial, {data: false}));
});

handlebarsOut = handlebar(context, options);
bench("handlebars", function() {
bench('handlebars', function() {
handlebar(context, options);
});

compatOut = compat(context, options);
bench("compat", function() {
bench('compat', function() {
compat(context, options);
});

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

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

bench("dust", function() {
dust.render(templateName, context, function(err, out) { });
bench('dust', function() {
dust.render(templateName, context, function() {});
});
} else {
bench('dust', error);
Expand All @@ -75,11 +74,11 @@ function makeSuite(bench, name, template, handlebarsOnly) {

ecoOut = ecoTemplate(context);

bench("eco", function() {
bench('eco', function() {
ecoTemplate(context);
});
} else {
bench("eco", error);
bench('eco', error);
}
}

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

bench("mustache", function() {
bench('mustache', function() {
Mustache.to_html(mustacheSource, context, mustachePartials);
});
} else {
bench("mustache", error);
bench('mustache', error);
}
}

Expand Down
Loading

0 comments on commit 9b1f9c7

Please sign in to comment.