Node.js based forum software built for the modern web
clean up conditional comments in the DOM; conditionals now treat undefined variables as false; closes #617
psychobunny090d35f306bd
diff --git a/public/src/templates.js b/public/src/templates.jsindex 6772f998b7..04972140a5 100644--- a/public/src/templates.js+++ b/public/src/templates.js@@ -320,14 +320,16 @@if (conditionalBlock[1]) {// there is an else statementif (!value) {- template = template.replace(matches[i], conditionalBlock[1]);+ template = template.replace(matches[i], conditionalBlock[1].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));} else {- template = template.replace(matches[i], conditionalBlock[0]);+ template = template.replace(matches[i], conditionalBlock[0].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));}} else {// regular if statementif (!value) {template = template.replace(matches[i], '');+ } else {+ template = template.replace(matches[i], matches[i].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));}}}@@ -351,6 +353,9 @@var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g');template = template.replace(regex, '');}+ //console.log (template);+ // clean up all undefined conditionals+ template = template.replace(/<!-- IF([\s\S]*?)ENDIF([\s\S]*?)-->/gi, '');return template;diff --git a/src/database/mongo.js b/src/database/mongo.jsindex c803e3a541..d6af3bc0b2 100644--- a/src/database/mongo.js+++ b/src/database/mongo.js@@ -188,8 +188,7 @@stats.raw = JSON.stringify(stats, null, 4);stats.mongo = true;- //remove this when andrew adds in undefined checking to templates- stats.redis = false;+callback(err, stats);});diff --git a/src/database/redis.js b/src/database/redis.jsindex b3a27ef895..d24573384b 100644--- a/src/database/redis.js+++ b/src/database/redis.js@@ -168,8 +168,6 @@}redisData.raw = JSON.stringify(redisData, null, 4);redisData.redis = true;- //remove this when andrew adds in undefined checking to templates- redisData.mongo = false;callback(null, redisData);});