summaryrefslogtreecommitdiff
path: root/src/node/eejs/index.js
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-12-06 18:35:35 +0100
committerMarcel Klehr <mklehr@gmx.net>2012-12-06 18:35:35 +0100
commitc909ed256f48eedc6748d7e046d72f7ff44e7fd5 (patch)
tree6316e43737f1831f74782dbba401fa4b8a090233 /src/node/eejs/index.js
parent0908caaf0d2c63358d392d3311befe5e854c4e85 (diff)
downloadetherpad-lite-c909ed256f48eedc6748d7e046d72f7ff44e7fd5.zip
Fix #1247, #1201: Don't cache eejs blocks!
Caching eejs blocks led to many unexpected bugs like having to restart the server after installing new plugins or the legendary connectingbar.gif issue...
Diffstat (limited to 'src/node/eejs/index.js')
-rw-r--r--src/node/eejs/index.js31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/node/eejs/index.js b/src/node/eejs/index.js
index 7b43de63..48185d80 100644
--- a/src/node/eejs/index.js
+++ b/src/node/eejs/index.js
@@ -28,18 +28,25 @@ var resolve = require("resolve");
exports.info = {
buf_stack: [],
block_stack: [],
- blocks: {},
file_stack: [],
args: []
};
+function getCurrentFile() {
+ return exports.info.file_stack[exports.info.file_stack.length-1];
+}
+
+function createBlockId(name) {
+ return getCurrentFile().path + '|' + name;
+}
+
exports._init = function (b, recursive) {
exports.info.buf_stack.push(exports.info.buf);
exports.info.buf = b;
}
exports._exit = function (b, recursive) {
- exports.info.file_stack[exports.info.file_stack.length-1].inherit.forEach(function (item) {
+ getCurrentFile().inherit.forEach(function (item) {
exports._require(item.name, item.args);
});
exports.info.buf = exports.info.buf_stack.pop();
@@ -59,29 +66,17 @@ exports.end_capture = function () {
}
exports.begin_define_block = function (name) {
- if (typeof exports.info.blocks[name] == "undefined")
- exports.info.blocks[name] = {};
exports.info.block_stack.push(name);
exports.begin_capture();
}
-exports.super = function () {
- exports.info.buf.push('<!eejs!super!>');
-}
-
exports.end_define_block = function () {
content = exports.end_capture();
- var name = exports.info.block_stack.pop();
- if (typeof exports.info.blocks[name].content == "undefined")
- exports.info.blocks[name].content = content;
- else if (typeof exports.info.blocks[name].content.indexOf('<!eejs!super!>'))
- exports.info.blocks[name].content = exports.info.blocks[name].content.replace('<!eejs!super!>', content);
-
- return exports.info.blocks[name].content;
+ return content;
}
exports.end_block = function () {
- var name = exports.info.block_stack[exports.info.block_stack.length-1];
+ var name = exports.info.block_stack.pop();
var renderContext = exports.info.args[exports.info.args.length-1];
var args = {content: exports.end_define_block(), renderContext: renderContext};
hooks.callAll("eejsBlock_" + name, args);
@@ -91,7 +86,7 @@ exports.end_block = function () {
exports.begin_block = exports.begin_define_block;
exports.inherit = function (name, args) {
- exports.info.file_stack[exports.info.file_stack.length-1].inherit.push({name:name, args:args});
+ getCurrentFile().inherit.push({name:name, args:args});
}
exports.require = function (name, args, mod) {
@@ -101,7 +96,7 @@ exports.require = function (name, args, mod) {
var paths = [];
if (exports.info.file_stack.length) {
- basedir = path.dirname(exports.info.file_stack[exports.info.file_stack.length-1].path);
+ basedir = path.dirname(getCurrentFile().path);
}
if (mod) {
basedir = path.dirname(mod.filename);