From 090d35f306bd8d471ab347d8f524afdb1bc244c3 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 15:48:30 -0500 Subject: [PATCH] clean up conditional comments in the DOM; conditionals now treat undefined variables as false; closes #617 --- public/src/templates.js | 9 +++++++-- src/database/mongo.js | 3 +-- src/database/redis.js | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 6772f998b7..04972140a5 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -320,14 +320,16 @@ if (conditionalBlock[1]) { // there is an else statement if (!value) { - template = template.replace(matches[i], conditionalBlock[1]); + template = template.replace(matches[i], conditionalBlock[1].replace(//gi, '')); } else { - template = template.replace(matches[i], conditionalBlock[0]); + template = template.replace(matches[i], conditionalBlock[0].replace(//gi, '')); } } else { // regular if statement if (!value) { template = template.replace(matches[i], ''); + } else { + template = template.replace(matches[i], matches[i].replace(//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(//gi, ''); return template; diff --git a/src/database/mongo.js b/src/database/mongo.js index 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.js index 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); });