mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +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 path = require("path");
|
||||
|
||||
exports.info = {
|
||||
buf_stack: [],
|
||||
block_stack: [],
|
||||
blocks: {},
|
||||
file_stack: [],
|
||||
};
|
||||
|
||||
exports.init = function (b, recursive) {
|
||||
if (!exports.info) {
|
||||
exports.info = {
|
||||
buf_stack: [],
|
||||
block_stack: [],
|
||||
blocks: {},
|
||||
filestack: [],
|
||||
}
|
||||
}
|
||||
exports.info.buf = b;
|
||||
}
|
||||
|
||||
|
@ -75,16 +74,17 @@ exports.require = function (name, args) {
|
|||
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);
|
||||
if ((name.indexOf("./") == 0 || name.indexOf("../") == 0) && exports.info.file_stack.length) {
|
||||
name = path.join(path.dirname(exports.info.file_stack[exports.info.file_stack.length-1]), 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);
|
||||
var res = ejs.render(
|
||||
fs.readFileSync(ejspath).toString(),
|
||||
args);
|
||||
var res = ejs.render(template, args);
|
||||
exports.info.buf = exports.info.buf_stack.pop();
|
||||
exports.info.file_stack.pop();
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<% var e = require("./eejs.js"); e.init(buf); %>
|
||||
|
||||
a
|
||||
<% e.begin_block("bar"); %>
|
||||
A
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<% var e = require("./eejs.js"); e.init(buf); %>
|
||||
|
||||
<% e.begin_define_block("foo"); %>
|
||||
YY
|
||||
<% e.end_define_block(); %>
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
"log4js" : "0.4.1",
|
||||
"jsdom-nocontextifiy" : "0.2.10",
|
||||
"async-stacktrace" : "0.0.2",
|
||||
"npm" : "1.1"
|
||||
"npm" : "1.1",
|
||||
"ejs" : "0.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint" : "*"
|
||||
|
|
Loading…
Reference in a new issue