Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add egs 0.1.3 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Dust](https://github.com/linkedin/dustjs) v1.2.1 ([website](http://linkedin.github.com/dustjs/))
- [Eco](https://github.com/sstephenson/eco) v1.1.0-rc-3
- [ECT](https://github.com/baryshev/ect) v0.4.8 ([website](http://ectjs.com/))
- [EGS](https://github.com/ckknight/egs) v0.1.3
- [EJS](https://github.com/visionmedia/ejs) v0.8.3
- [Fest](https://github.com/mailru/fest) v0.5.4
- [Gaikan](https://github.com/Deathspike/gaikan) v1.3.4
Expand Down
4 changes: 3 additions & 1 deletion benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var handlebars = require('./handlebars/handlebars.js');
var coffeekup = require('./coffeekup/coffeekup.js');
var underscore = require('./underscore/underscore.js');
var gaikan = require('./gaikan/gaikan.js');
var egs = require('./egs/egs.js');

var test = function(name, sample, cb) {
var i = 0;
Expand Down Expand Up @@ -69,7 +70,8 @@ var samples = [
{ name : 'Gaikan', sample: gaikan },
{ name : 'Hogan.js', sample : hogan },
{ name : 'Dust', sample : dust },
{ name : 'ECT', sample : ect }
{ name : 'ECT', sample : ect },
{ name : 'EGS', sample : egs }
];

var runTests = function () {
Expand Down
34 changes: 34 additions & 0 deletions egs/egs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var egs = require('egs');
var compiled;
var tplData;

module.exports.prepare = function (data, done) {
var template = egs.fromFile(__dirname + '/tpl_escaped.egs', { cache: true });
tplData = data;
template.ready().then(
function () {
compiled = template.sync;
done();
},
function (e) {
done(e);
});
};

module.exports.prepareUnescaped = function (data, done) {
var template = egs.fromFile(__dirname + '/tpl_unescaped.egs', { cache: true });
tplData = data;
template.ready().then(
function () {
compiled = template.sync;
done();
},
function (e) {
done(e);
});
};

module.exports.step = function (done) {
var html = compiled(tplData);
done(null, html);
};
14 changes: 14 additions & 0 deletions egs/tpl_escaped.egs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title><%= title %></title>
</head>
<body>
<p><%= text %></p>
<% for project in projects: %>
<a href="<%= project.url %>"><%= project.name %></a>
<p><%= project.description %></p>
<% else: %>
No projects
<% end %>
</body>
</html>
14 changes: 14 additions & 0 deletions egs/tpl_unescaped.egs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title><%=h title %></title>
</head>
<body>
<p><%=h text %></p>
<% for project in projects: %>
<a href="<%=h project.url %>"><%=h project.name %></a>
<p><%=h project.description %></p>
<% else: %>
No projects
<% end %>
</body>
</html>
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",
"egs": "0.1.3"
}
}