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

Commit bd3b6c0

Browse files
Clarify arguments passed to the template function by the flow.Loop component
1 parent acbabb5 commit bd3b6c0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/reference/flow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Loop
9292
There are several ways in which this option can be used:
9393

9494
* 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.
95-
* 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.
95+
* 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.
9696

9797
.. js:attribute:: options.templateParameters
9898

library/src/flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class Loop extends Sequence {
148148
})
149149
} else if (isFunction(this.options.template)) {
150150
this.options.content = this.options.templateParameters.map(
151-
p => this.options.template(p, this),
151+
(p, i) => this.options.template(p, i, this),
152152
)
153153
} else {
154154
console.warn('Missing or invalid template in loop, no content generated')

0 commit comments

Comments
 (0)