闲的无聊写的一个bigpipe的template engine
https://www.npmjs.com/package/btljs
html的格式 可以方便的扩展 异步执行(每解析一个tag都直接stream输出)
##Description
This is a template language aimed for bigpipe with async support
Template is parsed line by line.
No more messed-up&splitted-everywhere modules needed.
Write bigpipe in pure html
##Example
###Template
<html>
<head>
<title>Hello World</title>
</head>
<body>
<for start='0' end='10' step='+2' iterator='j'>
<script wait>
this.j++;
setTimeout(this.fulfill,2000) //2000ms
</script>
<p> Aloha!!!!</p>
</for>
</body>
</html>
###NodeJs
var koa = require('koa');
var fs = require('fs');
var Parser = require('./lib/parser');
var co = require('co');
var app = koa();
var html = fs.readFileSync('you file');
var parser = Parser();
co(function*() {
yield parser.load(html);
app.use(function* () {
this.type = 'html';
this.body = parser.stream();
});
});
app.listen(3000);
##Customization
###Add custom tag
parser.addTag('MyTag',function* (ele,push,context) {
push('<p>This is a test tag</p>');
});