Skip to content

Commit

Permalink
Add loop-over-range example to docs (fixes #107) (#111)
Browse files Browse the repository at this point in the history
* Add loop-over-range example to docs

* Update CHANGES
  • Loading branch information
uwefladrich authored Feb 12, 2024
1 parent b453412 commit 6a6f692
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Next release
============

Fixes
-----
- #107: Add loop-over-range example to docs


ScriptEngine 1.0.0rc3
=====================

Expand Down
11 changes: 11 additions & 0 deletions docs/sphinx/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ The list can also be specified in a separate ``base.context`` task, as in::
Note that the string defining the loop list must be enclosed in quotes because
of the braces.

As the previous examples illustrate, the loop specifier must be a valid YAML list. There is,
however, some freedom in the way that list is constructed. For example, a common pattern is to
loop over a contiguous range of numbers. This can be accomplished by combining the Jinja
``range()`` function and ``list`` filter::

- base.echo:
msg: "Looping from one to five, now at {{item+1}}"
loop: "{{range(5)|list}}"

In general, it is often useful to use the power of Jinja in order to contruct loops.

In all of the above examples, the loop index variable was not explicitly
named, which means it takes on its default name, ``item``. The ``item``
variable is added to the context for all jobs or tasks within the loop and can
Expand Down

0 comments on commit 6a6f692

Please sign in to comment.