-my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format);
-
-my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
-
-my @columns;
-
-my $should_loc = { map { $_ => 1 } qw(Status) };
-
-my $col_entry = sub {
- my $col = shift;
- # in tsv output, "#" is often a comment character but we use it for "id"
- delete $col->{title}
- if $col->{title} and $col->{title} =~ /^\s*#\s*$/;
- return {
- header => Encode::encode_utf8(loc($col->{title} || $col->{attribute})),
- map => $m->comp(
- "/Elements/ColumnMap",
- Name => $col->{attribute},
- Attr => 'value'
- ),
- should_loc => $should_loc->{$col->{attribute}},
- }
-};
-
-if ($PreserveNewLines) {
- my $col = [];
- push @columns, $col;
- for (@Format) {
- if ($_->{title} eq 'NEWLINE') {
- $col = [];
- push @columns, $col;
- }
- else {
- push @$col, $col_entry->($_);
- }
- }
-}
-else {
- push @columns, [map { $_->{attribute}
- ? $col_entry->($_)
- : () } @Format];
-}
-
-for (@columns) {
- $m->out(join("\t", map { $_->{header} } @$_)."\n");
-}
-