isloop Element

Create loops for flow control.

Syntax

<isloop
  (items = item_object ) | (iterator = iter_object) //required
  (alias = alias_name) | (var = var_name)
   status = status_name
   begin  = start_index
   end    = stop_index
   step   = increment_index
  ...
</isloop>
(items = item_object ) | (iterator = iter_object)

Allowed data type: expression.

You must include one of the following but not both:
  • items = item_object

    item_object is an expression that returns an object to iterate over. Attributes iterator and items can be used interchangeably.

  • iterator = iter_object

    iter_object is an expression that returns an object to iterate over. Attributes iterator and items can be used interchangeably.

items is preferred.

(alias = alias_name) | (var = var_name)

Name of the variable referencing the object in the iterable collection referenced in the current iteration.

You must include one of the following but not both:
  • alias = alias_name

    alias_name is the name of a variable referencing the object in the iterable collection referenced in the current iteration.

  • var = var_name

    var_name is the name of a variable referencing the object in the iterable collection referenced in the current iteration.

var is preferred.

status = status_name

status_name is the variable name referencing the loop status object. The loop status is used to query information such as the counter or whether it's the first item.

If status is specified, a loop status object is assigned to the given variable name. Below are the properties of the loop status object:

Attribute Description
count The number of iterations, starting with 1.
index The current index into the set of items, while iterating.
first True, if this is the first item while iterating (count == 1).
last True, if this is the last item while iterating.
odd True, if count is an odd value.
even True, if count is an even value.
begin = start_index

Allowed data type: expression.

start_index is an expression specifying a begin index for the loop. If the begin is greater than 0, the <isloop> skips the first x items and starts looping at the begin index. If begin is smaller than 0, 0 is used as the begin value.

end = stop_index

Allowed data type: expression.

stop_index is an expression specifying an end index (inclusive). If end is smaller than begin, the <isloop> is skipped.

step = increment_index

Allowed data type: expression.

increment_index is an expression specifying the step used to increase the index. If step is smaller than one, one is used as the step value.

Purpose

With <isloop> you can loop through the elements of a specified iterator. As an example, you can list data like categories, products, shipping and payment methods. <isloop> statements can be nested in one another.

Supporting Tags

  • Use <isbreak> to unconditionally terminate a loop.
  • Use <isnext> to jump forward in a loop

See <isbreak> and <isnext> for more information.

Example

<isloop iterator = "${pdict.Basket.products}" alias = "product">
<isprint value = "${product.name}"> <BR>
</isloop>
Note: The previous pdict.Basket is merely an example of using the Pipeline Dictionary as it relates to the Reference Application. It isn't the same as the Basket class in Salesforce B2C Commerce server-side JavaScript.