aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-04-09 21:44:36 +0200
committerEgil Moeller <egil.moller@freecode.no>2010-04-09 21:44:36 +0200
commitf9cc3b56b95cd471d4917de5d1b4797922e0e496 (patch)
tree9c18b0b9d0a77eb22814452223f3a27b5be564a1
parent144f883ad15efdb89b489cdc6fc539abbe35c31b (diff)
downloadetherpad-f9cc3b56b95cd471d4917de5d1b4797922e0e496.tar.gz
etherpad-f9cc3b56b95cd471d4917de5d1b4797922e0e496.tar.xz
etherpad-f9cc3b56b95cd471d4917de5d1b4797922e0e496.zip
Adde support for <%: %> and ejs_data in ejs-files, allowing templates to store/restore template-generated content.
-rw-r--r--infrastructure/framework-src/modules/ejs.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/infrastructure/framework-src/modules/ejs.js b/infrastructure/framework-src/modules/ejs.js
index bf14ed3..58c67bc 100644
--- a/infrastructure/framework-src/modules/ejs.js
+++ b/infrastructure/framework-src/modules/ejs.js
@@ -33,6 +33,7 @@
import("jsutils.*");
import("funhtml");
+import("etherpad.log");
jimport("java.lang.System.out.println");
jimport("net.appjet.ajstdlib.execution.executeCodeInNewScope");
@@ -75,12 +76,13 @@ var EjsScanner = function(source, left, right) {
this.double_left = left+'%%';
this.double_right = '%%'+right;
this.left_equal = left+'%=';
+ this.left_colon = left+'%:';
this.left_comment = left+'%#';
if(left=='[') {
- this.SplitRegexp = /(\[%%)|(%%\])|(\[%=)|(\[%#)|(\[%)|(%\]\n)|(%\])|(\n)/;
+ this.SplitRegexp = /(\[%%)|(%%\])|(\[%:)|(\[%=)|(\[%#)|(\[%)|(%\]\n)|(%\])|(\n)/;
}
else {
- this.SplitRegexp = new RegExp('('+this.double_left+')|(%%'+this.double_right+')|('+this.left_equal+')|('+this.left_comment+')|('+this.left_delimiter+')|('+this.right_delimiter+'\n)|('+this.right_delimiter+')|(\n)')
+ this.SplitRegexp = new RegExp('('+this.double_left+')|(%%'+this.double_right+')|('+this.left_equal+')|('+this.left_colon+')|('+this.left_equal+')|('+this.left_comment+')|('+this.left_delimiter+')|('+this.right_delimiter+'\n)|('+this.right_delimiter+')|(\n)')
}
this.source = source;
@@ -178,7 +180,7 @@ EjsBuffer.prototype = {
/* Adaptation from the Compiler of erb.rb */
EjsCompiler = function(source, left) {
- this.pre_cmd = ['var ___ejsO = "";'];
+ this.pre_cmd = ['var ejs_data = "";'];
this.post_cmd = new Array();
this.source = ' ';
if (source != null)
@@ -217,7 +219,7 @@ EjsCompiler.prototype = {
compile: function(options) {
options = options || {};
this.out = '';
- var put_cmd = "___ejsO += ";
+ var put_cmd = "ejs_data += ";
var insert_cmd = put_cmd;
var buff = new EjsBuffer(this.pre_cmd, this.post_cmd);
var content = '';
@@ -241,6 +243,7 @@ EjsCompiler.prototype = {
break;
case scanner.left_delimiter:
case scanner.left_equal:
+ case scanner.left_colon:
case scanner.left_comment:
scanner.stag = token;
if (content.length > 0)
@@ -277,6 +280,9 @@ EjsCompiler.prototype = {
case scanner.left_equal:
buff.push(insert_cmd + "(EjsScanner.to_text(" + content + "))");
break;
+ case scanner.left_colon:
+ buff.push(insert_cmd + content);
+ break;
}
scanner.stag = null;
content = '';
@@ -302,7 +308,7 @@ EjsCompiler.prototype = {
' with(_VIEW) {',
' with (_CONTEXT) {',
this.out,
- ' return ___ejsO;',
+ ' return ejs_data;',
' }',
' }',
'};'