projects
/
mkws-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9592167
)
mkws-paragraphs also handles explicitly undefined parameters.
author
Mike Taylor
<mike@indexdata.com>
Thu, 29 May 2014 15:21:57 +0000
(16:21 +0100)
committer
Mike Taylor
<mike@indexdata.com>
Thu, 29 May 2014 15:21:57 +0000
(16:21 +0100)
src/mkws-handlebars.js
patch
|
blob
|
history
diff --git
a/src/mkws-handlebars.js
b/src/mkws-handlebars.js
index
999c138
..
605282f
100644
(file)
--- a/
src/mkws-handlebars.js
+++ b/
src/mkws-handlebars.js
@@
-12,8
+12,10
@@
Handlebars.registerHelper('mkws-paragraphs', function(obj, count) {
var acc = [];
// For some reason, Handlebars provides the value
var acc = [];
// For some reason, Handlebars provides the value
- // {"hash":{},"data":{}} for undefined parameters
- if (count.hasOwnProperty('hash') || count == 0 || count > obj.length) {
+ // {"hash":{},"data":{}} for parameters that are not provided. So we
+ // have to be prepared for actual numbers, explicitly undefined
+ // values and this dumb magic value.
+ if (count === undefined || count.hasOwnProperty('hash') || count == 0 || count > obj.length) {
count = obj.length;
}
count = obj.length;
}