<%ARGS>
$i => undef
@Format => undef
$record => undef
$maxitems => undef
$Depth => undef
$Warning => undef
$ColumnMap => {}
$Class     => 'RTx__AssetTracker__Asset'
$Classes => ''
$TrailingNewline => 1
</%ARGS>

<%PERL>
foreach my $column (@Format) {
    if ( defined $column->{title} && $column->{title} eq 'NEWLINE' ) {
        $m->out( "\n" );
        next;
    }

    my @out;
    foreach my $subcol ( @{ $column->{output} } ) {
        my ($col) = ($subcol =~ /^__(.*?)__$/);
        unless ( $col ) {
            push @out, $subcol;
            next;
        }

        unless ( exists $ColumnMap->{$col}{'value'} ) {
            $ColumnMap->{$col}{'value'} = $m->comp(
                "/Elements/ColumnMap",
                Class => $Class,
                Name  => $col,
                Attr  => 'value'
            );
        }

        push @out, ProcessColumnMapValue(
            $ColumnMap->{$col}{'value'},
            Arguments => [$record, $i],
            Escape => 0,
        );
    }
    s/\t/ \[TAB\] /gs for @out;

    $m->out(@out) if @out;
    $m->out( "\t" );
}
#$m->out("\n");
</%PERL>
<%FILTER>
# replace line breaks with comma-space unless it is the last one, which will get scrubbed
s/\<br\>([^\t])/, $1/ig;

# no HTML
my $scrubber = HTML::Scrubber->new( deny => [ qw(*) ] );
#$scrubber->comment(0);
$_ = ( $scrubber->scrub($_) );

# The only newline should be at the end of the line
s/\n//g;
$_ .= "\n" if $TrailingNewline;
</%FILTER>
