mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 06:29:53 +01:00
Bugfixes for eejs
This commit is contained in:
parent
f6212f452c
commit
6fb0e00f03
4 changed files with 16 additions and 19 deletions
|
@ -23,15 +23,14 @@ var ejs = require("ejs");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
exports.init = function (b, recursive) {
|
exports.info = {
|
||||||
if (!exports.info) {
|
|
||||||
exports.info = {
|
|
||||||
buf_stack: [],
|
buf_stack: [],
|
||||||
block_stack: [],
|
block_stack: [],
|
||||||
blocks: {},
|
blocks: {},
|
||||||
filestack: [],
|
file_stack: [],
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
exports.init = function (b, recursive) {
|
||||||
exports.info.buf = b;
|
exports.info.buf = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,16 +74,17 @@ exports.require = function (name, args) {
|
||||||
if (!exports.info)
|
if (!exports.info)
|
||||||
exports.init(null);
|
exports.init(null);
|
||||||
|
|
||||||
if ((name.indexOf("./") == 0 || name.indexOf("../") == 0) && exports.info.file_stack) {
|
if ((name.indexOf("./") == 0 || name.indexOf("../") == 0) && exports.info.file_stack.length) {
|
||||||
name = path.join(exports.info.file_stack[exports.info.file_stack.length-1], name);
|
name = path.join(path.dirname(exports.info.file_stack[exports.info.file_stack.length-1]), name);
|
||||||
}
|
}
|
||||||
var ejspath = require.resolve(name)
|
var ejspath = require.resolve(name)
|
||||||
|
|
||||||
exports.info.file_stack.push(ejpath);
|
args.e = exports;
|
||||||
|
var template = '<% e.init(buf); %>' + fs.readFileSync(ejspath).toString();
|
||||||
|
|
||||||
|
exports.info.file_stack.push(ejspath);
|
||||||
exports.info.buf_stack.push(exports.info.buf);
|
exports.info.buf_stack.push(exports.info.buf);
|
||||||
var res = ejs.render(
|
var res = ejs.render(template, args);
|
||||||
fs.readFileSync(ejspath).toString(),
|
|
||||||
args);
|
|
||||||
exports.info.buf = exports.info.buf_stack.pop();
|
exports.info.buf = exports.info.buf_stack.pop();
|
||||||
exports.info.file_stack.pop();
|
exports.info.file_stack.pop();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<% var e = require("./eejs.js"); e.init(buf); %>
|
|
||||||
|
|
||||||
a
|
a
|
||||||
<% e.begin_block("bar"); %>
|
<% e.begin_block("bar"); %>
|
||||||
A
|
A
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<% var e = require("./eejs.js"); e.init(buf); %>
|
|
||||||
|
|
||||||
<% e.begin_define_block("foo"); %>
|
<% e.begin_define_block("foo"); %>
|
||||||
YY
|
YY
|
||||||
<% e.end_define_block(); %>
|
<% e.end_define_block(); %>
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
"log4js" : "0.4.1",
|
"log4js" : "0.4.1",
|
||||||
"jsdom-nocontextifiy" : "0.2.10",
|
"jsdom-nocontextifiy" : "0.2.10",
|
||||||
"async-stacktrace" : "0.0.2",
|
"async-stacktrace" : "0.0.2",
|
||||||
"npm" : "1.1"
|
"npm" : "1.1",
|
||||||
|
"ejs" : "0.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jshint" : "*"
|
"jshint" : "*"
|
||||||
|
|
Loading…
Reference in a new issue