Comparing version 0.1.0 to 0.1.1
30
index.js
@@ -10,3 +10,3 @@ /** | ||
var debuglog = require('debuglog')('yog-swig'); | ||
var tags = [ | ||
var tags = [ | ||
"script", | ||
@@ -37,3 +37,3 @@ "style", | ||
if (swigInstance){ | ||
if (swigInstance) { | ||
debuglog('use swig instance cache'); | ||
@@ -54,3 +54,3 @@ this.swig = swigInstance; | ||
// 加载内置扩展 | ||
tags.forEach(function (tag){ | ||
tags.forEach(function (tag) { | ||
var t = require('./tags/' + tag); | ||
@@ -61,3 +61,3 @@ swig.setTag(tag, t.parse, t.compile, t.ends, t.blockLevel || false); | ||
// 加载用户扩展 | ||
options.tags && Object.keys(options.tags).forEach(function (name){ | ||
options.tags && Object.keys(options.tags).forEach(function (name) { | ||
var t = options.tags[name]; | ||
@@ -67,3 +67,3 @@ swig.setTag(name, t.parse, t.compile, t.ends, t.blockLevel || false); | ||
options.filters && Object.keys(options.filters).forEach(function (name){ | ||
options.filters && Object.keys(options.filters).forEach(function (name) { | ||
var t = options.filters[name]; | ||
@@ -74,3 +74,7 @@ swig.setFilter(name, t); | ||
SwigWrap.prototype.makeStream = function(view, locals) { | ||
SwigWrap.prototype.cleanCache = function () { | ||
this.swig.invalidateCache(); | ||
}; | ||
SwigWrap.prototype.makeStream = function (view, locals) { | ||
debuglog('create [%s] render stream', view); | ||
@@ -80,3 +84,3 @@ return new EngineStream(this.swig, view, locals); | ||
var EngineStream = function(swig, view, locals){ | ||
var EngineStream = function (swig, view, locals) { | ||
this.swig = swig; | ||
@@ -91,6 +95,6 @@ this.view = view; | ||
EngineStream.prototype._read = function() { | ||
EngineStream.prototype._read = function () { | ||
var self = this; | ||
var state = self._readableState; | ||
if (this.reading){ | ||
if (this.reading) { | ||
return; | ||
@@ -100,3 +104,3 @@ } | ||
debuglog('start render [%s]', this.view); | ||
this.swig.renderFile(this.view, this.locals, function(error, output) { | ||
this.swig.renderFile(this.view, this.locals, function (error, output) { | ||
if (error) { | ||
@@ -113,3 +117,3 @@ debuglog('render [%s] failed', self.view); | ||
// 扩展swig内置函数,用于提供bigpipe支持 | ||
Swig.prototype._w = Swig.prototype._widget = function(layer, id, attr, options) { | ||
Swig.prototype._w = Swig.prototype._widget = function (layer, id, attr, options) { | ||
var self = this; | ||
@@ -123,3 +127,3 @@ var pathname = layer.resolve(id); | ||
return function(locals) { | ||
return function (locals) { | ||
var container = attr['container'] || attr['for']; | ||
@@ -136,3 +140,3 @@ | ||
compiled: function(locals) { | ||
compiled: function (locals) { | ||
var fn = self.compileFile(pathname, options); | ||
@@ -139,0 +143,0 @@ locals._yog.load(id); |
@@ -0,0 +0,0 @@ var fs = require('fs'), |
{ | ||
"name": "yog-swig", | ||
"version": "0.1.0", | ||
"description": "custom swig template, add some tag or filter ", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "mocha --reporter dot --check-leaks test/ut", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/ut", | ||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/ut" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fex-team/yog-swig.git" | ||
}, | ||
"keywords": [ | ||
"fis", | ||
"yog" | ||
], | ||
"author": "fansekey", | ||
"license": "BSD", | ||
"bugs": { | ||
"url": "https://github.com/fex-team/yog-swig/issues" | ||
}, | ||
"homepage": "https://github.com/fex-team/yog-swig", | ||
"dependencies": { | ||
"debuglog": "^1.0.1", | ||
"swig": "1.3.2" | ||
}, | ||
"devDependencies": { | ||
"express": "4.10.6", | ||
"chai": "^1.10.0", | ||
"istanbul": "~0.2.14", | ||
"mocha": "~1.20.1", | ||
"supertest": "^0.15.0", | ||
"yog2-kernel": "*", | ||
"yog-bigpipe": "*", | ||
"yog-view": "*" | ||
} | ||
} | ||
"name": "yog-swig", | ||
"version": "0.1.1", | ||
"description": "custom swig template, add some tag or filter ", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "mocha --reporter dot --check-leaks test/ut", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/ut", | ||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/ut" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fex-team/yog-swig.git" | ||
}, | ||
"keywords": [ | ||
"fis", | ||
"yog" | ||
], | ||
"author": "fansekey", | ||
"license": "BSD", | ||
"bugs": { | ||
"url": "https://github.com/fex-team/yog-swig/issues" | ||
}, | ||
"homepage": "https://github.com/fex-team/yog-swig", | ||
"dependencies": { | ||
"debuglog": "^1.0.1", | ||
"swig": "1.3.2" | ||
}, | ||
"devDependencies": { | ||
"express": "4.10.6", | ||
"chai": "^1.10.0", | ||
"istanbul": "~0.2.14", | ||
"mocha": "~1.20.1", | ||
"supertest": "^0.15.0", | ||
"yog2-kernel": "*", | ||
"yog-bigpipe": "*", | ||
"yog-view": "*" | ||
} | ||
} |
@@ -0,0 +0,0 @@ yog-swig |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ exports.compile = function(compiler, args, content, parents, options, blockName) { |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var ignore = 'ignore', |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var exports = module.exports; |
@@ -0,0 +0,0 @@ var ignore = 'ignore', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
569
22516