Class PageTemplate::LoopCommand
In: lib/PageTemplate/commands.rb
Parent: StackableCommand

LoopCommand is a StackableCommand. It requires an opening:

% if variable %
or [% unless variable %].

variable is fetched from the namespace.

On execution, if variable is true, and non-empty, then @commands is printed once with each item in the list placed in its own namespace and passed to the loop commands. (a list is defined as an object that responds to :map)

If variable is true, but does not respond to :map, then the list is called once

% else %
may be specified, modifying LoopCommand to print out

@elseCommands in case variable is false, or empty.

Methods

add   else   new   output   to_s  

Public Class methods

% in variable %
or [% loop variable %]

Or [% in variable: name %]

Public Instance methods

adds to @commands for the loop, or @elseCommands if ‘else’ has been passed.

An ‘else’ defines a list of commands to call when the loop is empty.

If variable is true, and non-empty, then @commands is printed once with each item in the list placed in its own namespace and passed to the loop commands. (a list is defined as an object that responds to :map)

If variable is true, but does not respond to :map, then the list is called once

[Validate]