From ecc1c315ccd01001fffac762c8c67d803031e7c6 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sun, 2 Feb 2014 13:53:19 -0500 Subject: [PATCH] closes #927 --- public/src/templates.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 2f2d9ad9fe..e9eee153a5 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -385,8 +385,14 @@ } else if (data[d] instanceof Object) { template = parse(data[d], d + '.', template); } else { - checkConditional(namespace + d, data[d]); - checkConditional('!' + namespace + d, !data[d]); + var key = namespace + d, + value = typeof data[d] === 'string' ? data[d].replace(/^\s+|\s+$/g, '') : data[d]; + + if (key === 'metaTags.content' && data[d]) { + console.log(typeof data[d] === 'string', data[d].replace(/^\s+|\s+$/g, '')); + } + checkConditional(key, value); + checkConditional('!' + key, !value); if (blockInfo && blockInfo.iterator) { checkConditional('@first', blockInfo.iterator === 0); @@ -395,7 +401,7 @@ checkConditional('!@last', blockInfo.iterator !== blockInfo.total); } - template = replace(namespace + d, data[d], template); + template = replace(key, value, template); } } } @@ -406,7 +412,8 @@ namespace = ''; } else { // clean up all undefined conditionals - template = template.replace(/(| -->))|()/gi, ''); + template = template.replace(//gi, 'ENDIF -->') + .replace(//gi, ''); } return template;