@@ -8,10 +8,19 @@ var forOwn = object.forOwn;
8
8
var helpers = module . exports ;
9
9
10
10
/**
11
- * Block helper that returns a block if the given collection is
12
- * empty. If the collection is not empty the inverse block is returned
13
- * (if supplied).
11
+ * Inline, subexpression, or block helper that returns true (or the block)
12
+ * if the given collection is empty, or false (or the inverse block, if
13
+ * supplied) if the colleciton is not empty .
14
14
*
15
+ * ```handlebars
16
+ * <!-- array: [] -->
17
+ * {{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
18
+ * <!-- results in: 'AAA' -->
19
+ *
20
+ * <!-- array: [] -->
21
+ * {{isEmpty array}}
22
+ * <!-- results in: true -->
23
+ * ```
15
24
* @param {Object } `collection`
16
25
* @param {Object } `options`
17
26
* @return {String }
@@ -35,9 +44,10 @@ helpers.isEmpty = function(collection, options) {
35
44
} ;
36
45
37
46
/**
38
- * Iterate over an array or object. If `collection` is an array,
39
- * `.forEach` is called, else if `collection` is an object, `.forOwn`
40
- * is called, otherwise the inverse block is returned.
47
+ * Block helper that iterates over an array or object. If
48
+ * an array is given, `.forEach` is called, or if an object
49
+ * is given, `.forOwn` is called, otherwise the inverse block
50
+ * is returned.
41
51
*
42
52
* @param {Object|Array } `collection` The collection to iterate over
43
53
* @param {Object } `options`
@@ -48,10 +58,10 @@ helpers.isEmpty = function(collection, options) {
48
58
49
59
helpers . iterate = function ( collection , options ) {
50
60
if ( Array . isArray ( collection ) ) {
51
- return forEach . apply ( forEach , arguments ) ;
52
- } else if ( util . isObject ( collection ) ) {
53
- return forOwn . apply ( forOwn , arguments ) ;
61
+ return forEach . apply ( null , arguments ) ;
62
+ }
63
+ if ( util . isObject ( collection ) ) {
64
+ return forOwn . apply ( null , arguments ) ;
54
65
}
55
66
return options . inverse ( this ) ;
56
67
} ;
57
-
0 commit comments