mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
clean up conditional comments in the DOM; conditionals now treat undefined variables as false; closes #617
This commit is contained in:
@@ -320,14 +320,16 @@
|
|||||||
if (conditionalBlock[1]) {
|
if (conditionalBlock[1]) {
|
||||||
// there is an else statement
|
// there is an else statement
|
||||||
if (!value) {
|
if (!value) {
|
||||||
template = template.replace(matches[i], conditionalBlock[1]);
|
template = template.replace(matches[i], conditionalBlock[1].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));
|
||||||
} else {
|
} else {
|
||||||
template = template.replace(matches[i], conditionalBlock[0]);
|
template = template.replace(matches[i], conditionalBlock[0].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// regular if statement
|
// regular if statement
|
||||||
if (!value) {
|
if (!value) {
|
||||||
template = template.replace(matches[i], '');
|
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');
|
var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g');
|
||||||
template = template.replace(regex, '');
|
template = template.replace(regex, '');
|
||||||
}
|
}
|
||||||
|
//console.log (template);
|
||||||
|
// clean up all undefined conditionals
|
||||||
|
template = template.replace(/<!-- IF([\s\S]*?)ENDIF([\s\S]*?)-->/gi, '');
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
|
|||||||
@@ -188,8 +188,7 @@
|
|||||||
stats.raw = JSON.stringify(stats, null, 4);
|
stats.raw = JSON.stringify(stats, null, 4);
|
||||||
|
|
||||||
stats.mongo = true;
|
stats.mongo = true;
|
||||||
//remove this when andrew adds in undefined checking to templates
|
|
||||||
stats.redis = false;
|
|
||||||
callback(err, stats);
|
callback(err, stats);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -168,8 +168,6 @@
|
|||||||
}
|
}
|
||||||
redisData.raw = JSON.stringify(redisData, null, 4);
|
redisData.raw = JSON.stringify(redisData, null, 4);
|
||||||
redisData.redis = true;
|
redisData.redis = true;
|
||||||
//remove this when andrew adds in undefined checking to templates
|
|
||||||
redisData.mongo = false;
|
|
||||||
|
|
||||||
callback(null, redisData);
|
callback(null, redisData);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user