From bef9c09598b13a820b0478c32afeb6a785597e22 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 26 Apr 2014 06:20:26 -0500 Subject: [PATCH] add cdata-like tag. --- lib/widget.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/widget.js b/lib/widget.js index f1198ef..059b2eb 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2025,7 +2025,9 @@ Element.prototype._parseTags = function(text) { , cap , slash , param - , attr; + , attr + , esc + , buf; for (;;) { if (cap = /^{(\/?)([\w\-,;!#]*)}/.exec(text)) { @@ -2033,6 +2035,22 @@ Element.prototype._parseTags = function(text) { slash = cap[1] === '/'; param = cap[2].replace(/-/g, ' '); + if (!slash && param === 'escape') { + buf = ''; + esc = true; + continue; + } else if (slash && param === 'escape') { + out += buf; + buf = ''; + esc = false; + continue; + } + + if (esc) { + buf += cap[0]; + continue; + } + if (param === 'open') { out += '{'; continue; @@ -2086,6 +2104,10 @@ Element.prototype._parseTags = function(text) { if (cap = /^[\s\S]+?(?={\/?[\w\-,;!#]*})/.exec(text)) { text = text.substring(cap[0].length); + if (esc) { + buf += cap[0]; + continue; + } out += cap[0]; continue; }