From 0cc136c3f6799612a3f042e033314bc3bc2ed8f4 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 23 Nov 2013 14:50:32 -0500 Subject: [PATCH] simplifying conditional logic in templates + fixed it so that it takes namespace into account --- public/src/templates.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 8f8099eb3c..763c7fe940 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -255,19 +255,6 @@ return data; } - function getConditionalBlock(regex, block, template) { - data = template.match(regex); - if (data == null) return; - - if (self.blocks && block !== undefined) self.blocks[block] = data[0]; - - data = data[0] - .replace("", "") - .replace("", ""); - - return data; - } - function setBlock(regex, block, template) { return template.replace(regex, block); } @@ -317,14 +304,12 @@ block = parse(data[d], namespace, block); template = setBlock(regex, block, template); } else { - var conditional = makeConditionalRegex(d), - block = getConditionalBlock(conditional, namespace, template); - - if (block && !data[d]) { + var conditional = makeConditionalRegex(namespace + d); + + if (conditional.test(template) && !data[d]) { template = template.replace(conditional, ''); } - template = replace(namespace + d, data[d], template); } }