---
name: "Catmandu::Exporter::Template"
section: "3pm"
platform: "linux"
package: "libcatmandu-template-perl"
version: "0.14-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Exporter::Template"
---

# Catmandu::Exporter::Template(3pm)

a TT2 Template exporter in Catmandu style

## NAME

Catmandu::Exporter::Template - a TT2 Template exporter in Catmandu style

## SYNOPSIS

```
    # From the command line
    echo '{"colors":["red","green","blue"]}' |
        catmandu convert JSON to Template --template `pwd`/xml.tt
    where xml.tt like:
    <colors>
    [% FOREACH c IN colors %]
       <color>[% c %]</color>
    [% END %]
    </colors>
    # From perl
    use Catmandu::Exporter::Template;
    my $exporter = Catmandu::Exporter::Template->new(
                fix => 'myfix.txt'
                xml => 1,
                template_before => '<path>/header.xml' ,
                template => '<path>/record.xml' ,
                template_after => '<path>/footer.xml' ,
           );
    $exporter->add_many($arrayref);
    $exporter->add_many($iterator);
    $exporter->add_many(sub { });
    $exporter->add($hashref);
    $exporter->commit; # trigger the template_after
    printf "exported %d objects\n" , $exporter->count;
```

## DESCRIPTION

This Catmandu::Exporter can be used to export records using Template Toolkit. If you are new to Catmandu see Catmandu::Tutorial.

## CONFIGURATION

- template

  Required. Must contain path to the template.

- xml

  Optional. Value: 0 or 1. Prepends xml header to the template.

- template\_before

  Optional. Prepend output to the export.

- template\_after

  Optional. Append output to the export.

- fix

  Optional. Apply Catmandu fixes while exporting.

- \[Template Toolkit configuration options\]

  You can also pass all Template Toolkit configuration options.

## SEE ALSO

Catmandu::Exporter, Template
