For more information... RTFM!

You are not logged in

Powered by Interchange version 5.7.0


Applies one or more of the Interchange text filters to an arbitrary value.

See the filters category for a list of standard filters.  You may also create your own custom filters.


  • [filter op] Text to transform [/filter]

Parameter Description Default
op One or more filters to apply to the body text. None
interpolate Parse Interchange tags, included in the body text, before this container tag executes. No


Tag expansion example

[filter uc] hello world [/filter]

Perl example

    op => $op,
    body => $text,

or similarly with positional parameters:

$Tag->filter($op, $text);


This tag applies one or more of the Interchange text filters to its body text.  You may use any of Interchange's standard filters, or you may define your own.  You may specify as many filters as you need, and they will be applied to the input text in the requested sequence.

For example, if you store the names of people in a database as "LASTNAME, Firstname", so that they sort properly, you might want to display the names as "Firstname Lastname".  The following example shows the filter call and its results:

[filter op="name namecase"]WALSH, Kevin[/filter]
Kevin Walsh
[tmp country]UK[/tmp]
[filter op="" interpolate=1][scratch country][/filter]
United Kingdom

Some tags, such as [cgi], [value] and [data] etc., have a "filter" parameter that you can use instead of passing their output to this tag.  For example:

[data table="products" column="artist" key="99-102" filter="name namecase"]

Custom filters

You can define your own filters in a GlobalSub, Sub or ActionMap, but the easiest method is to use CodeDef as follows:

CodeDef reverse Filter
CodeDef reverse Routine <<EOR
sub {
    my $val = shift;
    return scalar(reverse($val));

The above will reverse the characters in the body text as follows:

[filter reverse]Kevin Walsh[/filter]
hslaW niveK

The "$val", in the above CodeDef, is the value to be filtered.  You may filter the input in any way you see fit, and then and simply return the result to the caller.

You may pass parameters to your custom filters too.  The easiest way to explain is with an example:

CodeDef duplicate Filter
CodeDef duplicate Routine <<EOR
sub {
    my ($val, undef, $no) = @_;

    return $val x ($no || 1);

The above will duplicate the body text the specified number of times, or default to one copy if no parameter is specified, as follows:

[filter duplcate.3]Kevin[/filter]

See [PREFIX-filter] for a more efficient way of filtering values produced by looping sub-tags.



The name of one or more filters to apply to the body text.  If you need to specify more than one filter, then do so by separating the names from one another with a space.

See also

Categories:  Interchange Perl usage | Interchange tags
Last modified by: Gert van der Spoel
Modification date: Sunday 5 July 2009 at 2:58 PM (EDT)
Home  |  Legal nonsense  |  Privacy policy  |  Donations  |  Contact us