From c352b4c06d91b97cddbe3c32cfea0eeff76ba9b6 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 4 Apr 2014 13:28:46 -0400 Subject: [PATCH] imported latest templates.js, fixes #1327 --- public/src/templates.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 847941c87f..942bb46311 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -184,6 +184,11 @@ numblocks: numblocks }); + result = checkConditional(result, '@first', iterator === 0); + result = checkConditional(result, '!@first', iterator !== 0); + result = checkConditional(result, '@last', iterator === numblocks); + result = checkConditional(result, '!@last', iterator !== numblocks); + if (bind) { array[key][iterator].__template = block; } @@ -196,19 +201,12 @@ return namespace ? '' + block + '' : block; } - function parseValue(template, key, value, blockInfo) { + function parseValue(template, key, value) { value = typeof value === 'string' ? value.replace(/^\s+|\s+$/g, '') : value; template = checkConditional(template, key, value); template = checkConditional(template, '!' + key, !value); - if (blockInfo) { - template = checkConditional(template, '@first', blockInfo.iterator === 0); - template = checkConditional(template, '!@first', blockInfo.iterator !== 0); - template = checkConditional(template, '@last', blockInfo.iterator === blockInfo.total); - template = checkConditional(template, '!@last', blockInfo.iterator !== blockInfo.total); - } - return replace(template, key, value); } @@ -274,7 +272,7 @@ defineParent(obj[key], originalObj); template = parse(template, obj[key], bind, namespace + key + '.'); } else { - template = parseValue(template, namespace + key, obj[key], blockInfo); + template = parseValue(template, namespace + key, obj[key]); if (bind && obj[key]) { setupBindings({