Comparing version 0.0.16 to 0.0.17
22
index.js
@@ -22,7 +22,6 @@ /** | ||
]; | ||
var swigInstance; | ||
/** | ||
* Opitions 说明 | ||
* - `view` 模板文件 | ||
* - `locals` 模板变量 | ||
* - `views` 模板根目录 | ||
@@ -35,4 +34,4 @@ * - `loader` 模板加载器,默认自带,可选。 | ||
* 更多细节请查看 yog-view | ||
* | ||
* @return {Readable Stream} | ||
* | ||
* @return {Readable Stream} | ||
*/ | ||
@@ -48,3 +47,3 @@ var SwigWrap = module.exports = function SwigWrap(options, layer) { | ||
var swig = this.swig = new Swig(options); | ||
var swig = this.swig = swigInstance = options.cache && swigInstance || new Swig(options); | ||
this.options = swig.options; | ||
@@ -57,3 +56,3 @@ | ||
Readable.call(this, null); | ||
this.buzy = false; | ||
@@ -65,7 +64,14 @@ }; | ||
SwigWrap.prototype._read = function(n) { | ||
if (!this.buzy && this.options.view) { | ||
this.renderFile(this.options.view, this.options.locals); | ||
if (!this.buzy && this.view) { | ||
this.renderFile(this.view, this.locals); | ||
} | ||
}; | ||
SwigWrap.prototype.makeStream = function(view, locals) { | ||
Readable.call(this, null); | ||
this.view = view; | ||
this.locals = locals; | ||
return this; | ||
}; | ||
// 不推荐直接调用 | ||
@@ -72,0 +78,0 @@ // 最后在初始化 SwigWrap 的时候指定 view 已经 locals. |
{ | ||
"name": "yog-swig", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "custom swig template, add some tag or filter ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
21596
563