Skip to content

Node.js based forum software built for the modern web

imported latest templates.js, fixes #1327

psychobunnyc352b4c06d91
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 ? '<span data-binding="' + namespace + '">' + block + '</span>' : 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({