Name

filter — apply one or multiple filters

ATTRIBUTES

Attribute Pos. Req. Default Description
op Yes     List of filters to apply.
interpolate     0 interpolate input?
reparse     1 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

This tag applies one or multiple filters to the enclosed text.

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

No examples are available at this time. We do consider this a problem and will try to supply some.

NOTES

AVAILABILITY

filter is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/SystemTag/filter.coretag
Lines: 14


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: filter.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $

UserTag filter              Order        op
UserTag filter              hasEndTag
UserTag filter              PosNumber    1
UserTag filter              Version      $Revision: 1.4 $
UserTag filter              MapRoutine   Vend::Interpolate::filter_value

Source: lib/Vend/Interpolate.pm
Lines: 744

sub filter_value {
my($filter, $value, $tag, @passed_args) = @_;
#::logDebug("filter_value: filter='$filter' value='$value' tag='$tag'");
my @filters = Text::ParseWords::shellwords($filter); 
my @args;

if(! $Vend::Filters_initted++ and my $ref = $Vend::Cfg->{CodeDef}{Filter}) {
  while (my($k, $v) = each %{$ref->{Routine}}) {
    $Filter{$k} = $v;
  }
}

for (@filters) {
  next unless length($_);
  @args = @passed_args;
  if(/^[^.]*%/) {
    $value = sprintf($_, $value);
    next;
  }
  if (/^(\d+)([\.\$]?)$/) {
    my $len;
    return $value unless ($len = length($value)) > $1;
    my ($limit, $mod) = ($1, $2);
    unless($mod) {
      substr($value, $limit) = '';
    }
    elsif($mod eq '.') {
      substr($value, $1) = '...';
    }
    elsif($mod eq '$') {
      substr($value, 0, $len - $limit) = '...';
    }
    return $value;
    next;
  }
  while( s/\.([^.]+)$//) {
    unshift @args, $1;
  }
  if(/^\d+$/) {
    substr($value , $_) = ''
      if length($value) > $_;
    next;
  }
  if ( /^words(\d+)(\.?)$/ ) {
    my @str = (split /\s+/, $value);
    if (scalar @str > $1) {
      my $num = $1;
      $value = join(' ', @str[0..--$num]);
      $value .= $2 ? '...' : '';
    }
    next;
  }
  my $sub;
  unless ($sub = $Filter{$_} ||  Vend::Util::codedef_routine('Filter', $_) ) {
    logError ("Unknown filter '%s'", $_);
    next;
  }
  unshift @args, $value, $tag;
  $value = $sub->(@args);
}
#::logDebug("filter_value returns: value='$value'");
return $value;
}

AUTHORS

Interchange Development Group

SEE ALSO

Filter(7ic)

DocBook! Interchange!