The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

    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;

METHODS

new(xml => 0|1 , template_before => PATH, template => PATH , template_after => PATH)

Catmandu::Exporter::Template can be used to export data objects using Template Toolkit. The only required argument is 'template' which points to a file to render for each exported object. Set the 'template_before' and 'template_before' to add output at the start and end of the export. Optionally provide an 'xml' indicator to include a XML header.

commit

Commit all changes and execute the template_after if given.

SEE ALSO

Catmandu::Exporter, Template