Collection Operators

When we need to work with collections, these operators will help with your markdown.

List of Operators

{{isEmpty}}

Inline, subexpression, or block helper that returns true (or the block) if the given collection is empty, or false (or the inverse block, if supplied) if the collection is not empty.

Params

  • collection {Object}
  • options {Object}
  • returns {String}

Example

<!-- array: [] -->
{{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
<!-- results in: 'AAA' -->

<!-- array: [] -->
{{isEmpty array}}
<!-- results in: true -->

{{iterate}}

Block helper that iterates over an array or object. If an array is given, .forEach is called, or if an object is given, .forOwn is called, otherwise the inverse block is returned.

Params

  • collection {Object|Array}: The collection to iterate over
  • options {Object}
  • returns {String}