mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 12:01:17 +01:00
added if / else logic to templates
This commit is contained in:
@@ -306,8 +306,25 @@
|
||||
} else {
|
||||
var conditional = makeConditionalRegex(namespace + d);
|
||||
|
||||
if (conditional.test(template) && !data[d]) {
|
||||
template = template.replace(conditional, '');
|
||||
var conditionalBlock = conditional.exec(template);
|
||||
|
||||
if (conditionalBlock !== null) {
|
||||
conditionalBlock = conditionalBlock[0].split('<!-- ELSE -->');
|
||||
|
||||
if (conditionalBlock[1]) {
|
||||
// there is an else statement
|
||||
if (!data[d]) {
|
||||
template = template.replace(conditional, conditionalBlock[1]);
|
||||
} else {
|
||||
template = template.replace(conditional, conditionalBlock[0]);
|
||||
}
|
||||
|
||||
} else {
|
||||
// regular if
|
||||
if (!data[d]) {
|
||||
template = template.replace(conditional, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template = replace(namespace + d, data[d], template);
|
||||
|
||||
Reference in New Issue
Block a user