Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
<% extend 'templateName' %>
<% content %>
Rendering 100000 templates:
ECT: 656ms
Hogan.js: 661ms
Swig: 1337ms
Eco: 1810ms
EJS: 2975ms
Jade: 9533ms
users_list..jst.skim. Во время деплоя они один раз компилируются в users_list..js и больше Skim-компилятор не разу не вызывается. В итоге не нужно тянуть кучу библиотек на клиента и скорость работы сайты быстрее (так как время на компиляцию шаблонов = 0).- %(home blog forum).each do |section|
a href='#" section
Проблема в низкой инф. плотности HTML — нужно просто сменить синтаксис и все проблемы решаться сами.
akdubya authored a year ago
Rendering 100000 templates:
ECT: 673ms
Hogan.js: 685ms
Swig: 1390ms
Dust: 1761ms
Eco: 2347ms
EJS: 3411ms
Jade: 9013ms
$ node ./benchmark.js
Rendering 100000 templates:
ECT: 491ms
Hogan.js: 501ms
Swig: 1112ms
Dust: 302ms
Eco: 1349ms
EJS: 2228ms
Jade: 6293ms
$ git diff
diff --git a/dust/dust.js b/dust/dust.js
index 8b7a52b..fc51c52 100644
--- a/dust/dust.js
+++ b/dust/dust.js
@@ -6,12 +6,13 @@ var tplData;
module.exports.prepare = function (data, done) {
tplData = data;
- compiled = dust.compileFn(str);
+ compiled = dust.compile(str, 'test');
+ dust.loadSource(compiled);
done();
};
module.exports.step = function (done) {
- var html = compiled(tplData, function(err, html) {
+ dust.render('test', tplData, function(err, html) {
done();
});
-};
\ No newline at end of file
+};
ECT: 513ms
Swig: 1059ms
ECT: 874ms
Swig: 1087ms
module.exports.prepare = function (data, done) {
tplData = data;
renderer.render('tpl.ect', tplData, function(err, html) {
done();
});
};
module.exports.step = function (done) {
renderer.render('tpl.ect', tplData, function(err, html) {
done();
});
};
{% block test %}
{% endblock %}
{% extends 'main.swig' %}
{% block test %}
inherit
{% endblock %}
<% content 'test' %>
<% extend 'main.ect' %>
<% block 'test' : %>
inherit
<% end %>
<% block 'test' : %>
main
<% end %>
<% extend 'main.ect' %>
<% block 'test' : %>
inherit
<% end %>
module.exports.step = function (done) {
renderer.render('tpl.ect', tplData, function(err, html) {
console.log(err, html);
done();
});
};
<% block 'test' : %>
main
<% end %>
<% content 'test' %>
ECT — новый JavaScript шаблонизатор со вкусом кофе