iWebPress iWebPress: User Guide

4.2.5. Functions

While using keywords above is a powerful way to accomplish many tasks, sometimes a programming function is necessary to accomplish certain tasks. The iWebPress Markup Language version 1.0 engine includes one powerful function utilized across almost all of our templates. Please be aware that IML version 1.2 is already in the works and will include many new functions and features.

ifSet and endIfSet

ifSet is a function used to check if a set of variables is set or defined. For example, suppose you want to include an image, but only if one exists. You can easily do so by surrounding the image and any other code or elements in your template with ifSet directives.

ifSet can be placed either in plain text, right in your template (in which case they will be removed before the template is displayed), or they can be placed in anchors or HTML comments, both of which will be hidden from view. The following example places them in comments:

<-- %ifSet(any)% -->
The first image is called: %imageName(1)%
<-- %endIfSet% -->

If the first image had a name, then the entire sentence The first image is called: Image Name would be printed. Otherwise, nothing would be printed. As you can see, you simply surround the block of code you want to check, and ifSet works.

You may also note the presence of a flag called any. This signifies whether ALL or ANY of the variables within the ifSet block are necessary for the block to print.

For example, %ifSet(any)% will print if any of the variables inside are defined. If none of them are defined, the block will not print.

%ifSet(all)% blocks will only print if all of the variables within the block are defined. If even one of the variables is empty, the entire block will not print.