Otera.Loop (otera v0.1.0)

Copy Markdown View Source

The loop variable inside a {% for %} block, like the LoopContext of Jinja2.

It has index, index0, revindex, revindex0, first, last, length, depth, depth0, previtem and nextitem, the methods cycle and changed, and for a recursive loop it can be called with the items of the next level.

Each iteration gets a new Loop with the same ref. changed keeps its last value for the ref in Otera.State.

Summary

Functions

Returns true when values differ from the values of the previous call in this loop, like loop.changed(*values).

Returns the attribute name of loop.

Returns the items after the current one as {item, loop} pairs, which Python gives when a template iterates over the loop.

Functions

changed?(loop, values)

@spec changed?(
  %Otera.Loop{
    depth0: term(),
    index0: term(),
    items: term(),
    recurse: term(),
    ref: term()
  },
  list()
) :: boolean()

Returns true when values differ from the values of the previous call in this loop, like loop.changed(*values).

get(loop, name)

@spec get(
  %Otera.Loop{
    depth0: term(),
    index0: term(),
    items: term(),
    recurse: term(),
    ref: term()
  },
  String.t()
) :: term()

Returns the attribute name of loop.

remaining(loop)

@spec remaining(%Otera.Loop{
  depth0: term(),
  index0: term(),
  items: term(),
  recurse: term(),
  ref: term()
}) :: [
  {term(),
   %Otera.Loop{
     depth0: term(),
     index0: term(),
     items: term(),
     recurse: term(),
     ref: term()
   }}
]

Returns the items after the current one as {item, loop} pairs, which Python gives when a template iterates over the loop.