Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Clarify arguments passed to the template function by the flow.Loop co…
Browse files Browse the repository at this point in the history
…mponent
  • Loading branch information
FelixHenninger committed May 9, 2017
1 parent acbabb5 commit bd3b6c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/reference/flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Loop
There are several ways in which this option can be used:

* First it can be a **single component** of any type, an :js:class:`html.Screen`, (most likely) a :js:class:`flow.Sequence` or even another :js:class:`flow.Loop`. This component will be :js:func:`cloned <clone>` for each iteration, and the :js:attr:`parameters <options.parameters>` substituted on each copy so that the repetitions can differ from another.
* Second, it can be a **function** that creates and returns the component for each iteration. This function will receive each set of :js:attr:`templateParameters <options.templateParameters>` in turn as a first argument (and, optionally, the index as a second argument). The advantage of this method is a greater flexibility: More logic can be used at every step to customize every iteration.
* Second, it can be a **function** that creates and returns the component for each iteration. This function will receive each set of :js:attr:`templateParameters <options.templateParameters>` in turn as a first argument (and, optionally, the index as a second argument, and the loop component itself as a third). The advantage of this method is a greater flexibility: Additional logic can be used at every step to customize every iteration.

.. js:attribute:: options.templateParameters

Expand Down
2 changes: 1 addition & 1 deletion library/src/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class Loop extends Sequence {
})
} else if (isFunction(this.options.template)) {
this.options.content = this.options.templateParameters.map(
p => this.options.template(p, this),
(p, i) => this.options.template(p, i, this),
)
} else {
console.warn('Missing or invalid template in loop, no content generated')
Expand Down

0 comments on commit bd3b6c0

Please sign in to comment.