Bugfix
This commit is contained in:
parent
92dc3e59d6
commit
f6212f452c
|
@ -21,6 +21,7 @@
|
|||
|
||||
var ejs = require("ejs");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
exports.init = function (b, recursive) {
|
||||
if (!exports.info) {
|
||||
|
@ -28,7 +29,7 @@ exports.init = function (b, recursive) {
|
|||
buf_stack: [],
|
||||
block_stack: [],
|
||||
blocks: {},
|
||||
level: 1
|
||||
filestack: [],
|
||||
}
|
||||
}
|
||||
exports.info.buf = b;
|
||||
|
@ -71,13 +72,22 @@ exports.begin_block = exports.begin_define_block;
|
|||
|
||||
exports.require = function (name, args) {
|
||||
if (args == undefined) args = {};
|
||||
if (exports.info)
|
||||
if (!exports.info)
|
||||
exports.init(null);
|
||||
|
||||
if ((name.indexOf("./") == 0 || name.indexOf("../") == 0) && exports.info.file_stack) {
|
||||
name = path.join(exports.info.file_stack[exports.info.file_stack.length-1], name);
|
||||
}
|
||||
var ejspath = require.resolve(name)
|
||||
|
||||
exports.info.file_stack.push(ejpath);
|
||||
exports.info.buf_stack.push(exports.info.buf);
|
||||
var res = ejs.render(
|
||||
fs.readFileSync(require.resolve(name)).toString(),
|
||||
fs.readFileSync(ejspath).toString(),
|
||||
args);
|
||||
if (exports.info)
|
||||
exports.info.buf = exports.info.buf_stack.pop();
|
||||
exports.info.file_stack.pop();
|
||||
|
||||
if (exports.info.buf)
|
||||
exports.info.buf.push(res);
|
||||
return res;
|
||||
|
|
Loading…
Reference in New Issue