Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [Jade](https://github.com/visionmedia/jade) v0.28.1 ([website](http://jade-lang.com/))
- [Swig](https://github.com/paularmstrong/swig) v0.13.5
- [Underscore](https://github.com/documentcloud/underscore) v1.4.4 ([website](http://underscorejs.org/))
- [Marko](https://github.com/marko-js/marko) v4.5.2([website](http://markojs.com/))

## Test environment

Expand All @@ -25,6 +26,11 @@
## Results

Rendering 100000 templates:

Marko
Escaped : 1086ms
Unescaped : 152ms
Total : 1238ms

ECT
Escaped : 2180ms
Expand Down Expand Up @@ -100,6 +106,7 @@
Escaped : 18330ms
Unescaped : 12095ms
Total : 30425ms


## Usage

Expand Down
3 changes: 2 additions & 1 deletion benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var data = require('./data');

var count = 100000;
var marko = require('./marko/marko.js');
var ect = require('./ect/ect.js');
var ejs = require('./ejs/ejs.js');
var ejsWithoutWith = require('./ejs-without-with/ejs.js');
Expand Down Expand Up @@ -54,7 +55,7 @@ var testUnescaped = function(name, sample, cb) {
};

var samples = [

{ name : 'Marko', sample : marko },
{ name : 'Jade', sample : jade },
{ name : 'CoffeeKup', sample : coffeekup },
{ name : 'Jade without `with`', sample : jadeWithoutWith },
Expand Down
23 changes: 23 additions & 0 deletions marko/marko.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var fs = require('fs');
var markoCompiler = require('marko/compiler');
markoCompiler.configure({ writeToDisk: false });
var marko = require('marko');
var compiled;
var tplData;

module.exports.prepare = function (data, done) {
compiled = marko.load(require.resolve('./tpl_escaped.marko'));
tplData = data;
done();
};

module.exports.prepareUnescaped = function (data, done) {
compiled = marko.load(require.resolve('./tpl_unescaped.marko'));
tplData = data;
done();
};

module.exports.step = function (done) {
var html = compiled.renderSync(tplData).toString();
done(undefined, html);
};
10 changes: 10 additions & 0 deletions marko/tpl_escaped.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
html
head
title -- ${input.title}
body
p -- ${input.text}
if(input.projects.length)
a for(project in input.projects) -- ${project.name}
p -- ${project.description}
else
-- No Projects
10 changes: 10 additions & 0 deletions marko/tpl_unescaped.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
html
head
title -- $!{input.title}
body
p -- $!{input.text}
if(input.projects.length)
a for(project in input.projects) -- $!{project.name}
p -- $!{project.description}
else
-- No Projects
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"handlebars": "1.0.9",
"coffeekup": "0.3.1",
"underscore": "1.4.4",
"gaikan": "1.3.4"
"gaikan": "1.3.4",
"marko": "4.5.2"
}
}