Comparing version 0.0.6 to 0.0.7
25
index.js
@@ -6,4 +6,2 @@ /** | ||
var Swig = require('swig').Swig; | ||
var util = require("util"); | ||
var EventEmitter = require("events").EventEmitter; | ||
var loader = require('./lib/loader.js'); | ||
@@ -66,29 +64,10 @@ var tags = [ | ||
}); | ||
EventEmitter.call(this); | ||
}; | ||
util.inherits(SwigWrap, EventEmitter); | ||
SwigWrap.prototype.renderFile = function(path, data) { | ||
var self = this; | ||
this.swig.renderFile(path, data, function(err, output) { | ||
if (err) { | ||
return self.emit('error', err); | ||
} | ||
// 这里支持 chunk 输出内容。 | ||
// 可以先输出部分,如: | ||
// self.emit('data', 'chunk content'); | ||
// self.emit('flush'); | ||
self.emit('end', output); | ||
}); | ||
SwigWrap.prototype.renderFile = function() { | ||
return this.swig.renderFile.apply(this.swig, arguments); | ||
}; | ||
SwigWrap.prototype.destroy = function() { | ||
this.emit('destroy'); | ||
this.removeAllListeners(); | ||
this.swig = null; | ||
}; |
{ | ||
"name": "yog-swig", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "custom swig template, add some tag or filter ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,5 +10,4 @@ var exports = module.exports; | ||
exports.compile = function(compiler, args, content, parents, options, blockName) { | ||
content.unshift('<body>'); | ||
content.push('<!--FIS_JS_HOOK--></body>'); | ||
return compiler(content, parents, options, blockName); | ||
var code = compiler(content, parents, options, blockName); | ||
return '_output += "<body>";' + code + '_output += _ctx._yog.JS_HOOK + "</body>" + _ctx._yog.BIGPIPE_HOOK;'; | ||
}; | ||
@@ -15,0 +14,0 @@ |
var exports = module.exports; | ||
exports.compile = function(compiler, args, content, parents, options, blockName) { | ||
content.unshift('<head>'); | ||
content.push('<!--FIS_CSS_HOOK--></head>'); | ||
var code = compiler(content, parents, options, blockName); | ||
return code; | ||
return '_output += "<head>";' + code + '_output += _ctx._yog.CSS_HOOK + "</head>";'; | ||
}; | ||
@@ -9,0 +7,0 @@ |
13909
330