3.1. Understanding Tag Syntax

Interchange uses a style similar to HTML, but with [square brackets] replacing <chevrons>. The parameters that can be passed are similar, where a parameter="parameter value" can be passed.

Summary:

    [tag parameter]             Tag called with positional parameter
    [tag parameter=value]       Tag called with named parameter
    [tag parameter="the value"] Tag called with space in parameter
    [tag 1 2 3]                 Tag called with multiple positional parameters
    [tag foo=1 bar=2 baz=3]     Tag called with multiple named parameters
    [tag foo=`2 + 2`]           Tag called with calculated parameter
    [tag foo="[value bar]"]     Tag called with tag inside parameter
    [tag foo="[value bar]"]
        Container text.         Container tag.
    [/tag]

Most tags can accept some positional parameters. This makes parsing faster and is, in most cases, simpler to write.

The following is an example tag:

    [value name=city]

This tag causes Interchange to look in the user form value array and return the value of the form parameter city, which might have been set with:

    City: <INPUT TYPE=text NAME=city VALUE="[value city]">


Note: Keep in mind that the value was pre-set with the value of city (if any). It uses the positional style, meaning name is the first positional parameter for the [value ...] tag. Positional parameters cannot be derived from other Interchange tags. For example, [value [value formfield]] will not work. But, if the named parameter syntax is used, parameters can contain other tags. For example:

    [value name="[value formfield]"]]

There are exceptions to the above rule when using list tags such as [item-list], [loop], [query] and others. These tags, and their exceptions, are explained in their corresponding sections.

Many Interchange tags are container tags. For example:

    [set Checkout]
        mv_nextpage=ord/checkout
        mv_todo=return
    [/set]

Tags and parameter names are not case sensitive, so [VALUE NAME=something] and [value name=something] work the same. The Interchange development convention is to type HTML tags in upper case and Interchange tags in lower case. This makes pages and tags easier to read.

Single quotes work the same as double quotes and can prevent confusion. For example:

    [value name=b_city set='[value city]']

Backticks should be used with extreme caution since they cause the parameter contents to be evaluated as Perl code using the [calc] tag. For example:

    [value name=row_value set=`$row_value += 1`]

is the same as

    [value name=row_value set="[calc]$row_value += 1[/calc]"]

Vertical bars can also be used as quoting characters, but have the unique behavior of stripping leading and trailing whitespace. For example:

    [loop list="
        k1    A1    A2    A3
        k2    B1    B2    B3"]
        [loop-increment][loop-code]
    [/loop]

could be better expressed as:

    [loop list=|
            k1    A1    A2    A3
            k2    B1    B2    B3
    |]
        [loop-increment][loop-code]
    [/loop]

How the result of the tag is displayed depends on if it is a container or a standalone tag. A container tag has a closing tag (for example, [tag] stuff [/tag]). A standalone tag has no end tag (for example, [area href=somepage]. Note that [page] and [order] are not container tags. ([/page] and [/order] are simple macros.)

A container tag will have its output re-parsed for more Interchange tags by default. To inhibit this behavior, set the attribute reparse to 0. However, it has been found that the default re-parsing is almost always desirable. On the other hand, the output of a standalone tag will not be re-interpreted for Interchange tag constructs (with some exceptions, like [include file].

Most container tags will not have their contents interpreted (Interchange tags parsed) before being passed the container text. Exceptions include [calc], [currency] and [seti]. All tags accept the interpolate=1 tag modifier, which causes the interpretation to take place.