v1.18.x
psychobunny 11 years ago
parent d27eb17b32
commit 31d8f13f7b

@ -83,7 +83,7 @@
} }
function makeStatementRegex(key) { function makeStatementRegex(key) {
return new RegExp("([\\s]*<!--[\\s]*IF " + key + "[\\s]*-->[\\s]*)|([\\s]*<!--[\\s]*ENDIF " + key + "[\\s]*-->[\\s]*)", 'gi'); return new RegExp("([\\s]*<!--[\\s]*IF " + key + "[\\s]*-->)|(<!--[\\s]*ENDIF " + key + "[\\s]*-->[\\s]*)", 'gi');
} }
function registerGlobals(obj) { function registerGlobals(obj) {
@ -108,16 +108,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].replace(statement, '').replace(/(^[\s]*)|([\s]*$)/gi, '')); template = template.replace(matches[i], conditionalBlock[1].replace(statement, '').replace(/(^[\r\n\t]*)|([\r\n\t]*$)/gi, ''));
} else { } else {
template = template.replace(matches[i], conditionalBlock[0].replace(statement, '').replace(/(^[\s]*)|([\s]*$)/gi, '')); template = template.replace(matches[i], conditionalBlock[0].replace(statement, '').replace(/(^[\r\n\t]*)|([\r\n\t]*$)/gi, ''));
} }
} else { } else {
// regular if statement // regular if statement
if (!value) { if (!value) {
template = template.replace(matches[i], ''); template = template.replace(matches[i], '');
} else { } else {
template = template.replace(matches[i], matches[i].replace(statement, '').replace(/(^[\s]*)|([\s]*$)/gi, '')); template = template.replace(matches[i], matches[i].replace(statement, '').replace(/(^[\r\n\t]*)|([\r\n\t]*$)/gi, ''));
} }
} }
} }
@ -294,10 +294,10 @@
namespace = ''; namespace = '';
} else { } else {
// clean up all undefined conditionals // clean up all undefined conditionals
template = setBindContainer(template.replace(/\s*<!-- ELSE -->\s*/gi, 'ENDIF -->\r\n') template = template.replace(/\s*<!-- ELSE -->\s*/gi, 'ENDIF -->\r\n')
.replace(/\s*<!-- IF([\s\S]*?)ENDIF([\s\S]*?)-->/gi, '') .replace(/\s*<!-- IF([\s\S]*?)ENDIF([\s\S]*?)-->/gi, '')
.replace(/\s*<!-- BEGIN([\s\S]*?)END ([\s\S]*?)-->/gi, '') .replace(/\s*<!-- BEGIN([\s\S]*?)END ([\s\S]*?)-->/gi, '')
.replace(/\s*<!-- ENDIF ([\s\S]*?)-->\s*/gi, ''), bind); .replace(/\s*<!-- ENDIF ([\s\S]*?)-->\s*/gi, '');
template = setBindContainer(template, bind); template = setBindContainer(template, bind);
} }

Loading…
Cancel
Save