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

IfCommand is a StackableCommand. It requires an opening:

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

On execution, if variable is true, then the contents of IfCommand‘s @commands is printed.

% else %
may be specified for either if or unless, after which

objects are added to @falseCommands, and are printed if variable is false, instead.

Methods

add   else   elsif   new   output   to_s  

Public Class methods

command must match "if <value>" or "unless <value>"

Public Instance methods

Add the command to the @trueCommands or @falseCommands block, depending on if the command is an ‘if’ or ‘unless’ and if ‘else’ has been called.

an ‘else’ will modify the command, switching it from adding to @trueCommands to adding to @falseCommands, or vice versa.

an elseif will create a new condition.

If @value is true within the context of namespace, then print the output of @trueCommands. Otherwise, print the output of @falseCommands

[Validate]