diff options
author | Egil Moeller <egil.moller@freecode.no> | 2012-03-13 20:32:56 +0100 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2012-03-13 20:32:56 +0100 |
commit | a5366a0a161cf1ecfc8e9beb1da8d322402628f1 (patch) | |
tree | 950cf7e899b29b957b9988cad1a44ae9e14486dc /src/node/eejs | |
parent | 05c2e0fde521b17a8229ac4d2f0478c71bef17d4 (diff) | |
download | etherpad-lite-a5366a0a161cf1ecfc8e9beb1da8d322402628f1.zip |
Integrated hooks into templates and provided a blokc/hook for the left and right editbar menu
Diffstat (limited to 'src/node/eejs')
-rw-r--r-- | src/node/eejs/examples/foo.ejs | 2 | ||||
-rw-r--r-- | src/node/eejs/index.js | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/node/eejs/examples/foo.ejs b/src/node/eejs/examples/foo.ejs index 3778b59a..daee5f8e 100644 --- a/src/node/eejs/examples/foo.ejs +++ b/src/node/eejs/examples/foo.ejs @@ -2,4 +2,6 @@ <% e.begin_define_block("foo"); %> YY + <% e.super(); %> + ZZ <% e.end_define_block(); %> diff --git a/src/node/eejs/index.js b/src/node/eejs/index.js index 9291a341..a16ddc80 100644 --- a/src/node/eejs/index.js +++ b/src/node/eejs/index.js @@ -16,12 +16,13 @@ /* Basic usage: * - * require("./eejs").require("./examples/foo.ejs") + * require("./index").require("./examples/foo.ejs") */ var ejs = require("ejs"); var fs = require("fs"); var path = require("path"); +var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js"); exports.info = { buf_stack: [], @@ -62,17 +63,26 @@ exports.begin_define_block = function (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; } exports.end_block = function () { - var res = exports.end_define_block(); - exports.info.buf.push(res); + var name = exports.info.block_stack[exports.info.block_stack.length-1]; + var args = {content: exports.end_define_block()}; + hooks.callAll("eejsBlock_" + name, args); + exports.info.buf.push(args.content); } exports.begin_block = exports.begin_define_block; |