Scroll to navigation

Catmandu::Exporter::Template(3pm) User Contributed Perl Documentation Catmandu::Exporter::Template(3pm)


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


    # From the command line
    echo '{"colors":["red","green","blue"]}' | 
        catmandu convert JSON to Template --template `pwd`/
    where like:
    [% FOREACH c IN colors %]
       <color>[% c %]</color>
    [% END %]
    # 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(sub { });
    $exporter->commit; # trigger the template_after
    printf "exported %d objects\n" , $exporter->count;


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


Required. Must contain path to the template.
Optional. Value: 0 or 1. Prepends xml header to the template.
Optional. Prepend output to the export.
Optional. Append output to the export.
Optional. Apply Catmandu fixes while exporting.
[Template Toolkit configuration options]
You can also pass all Template Toolkit configuration options.


Catmandu::Exporter, Template

2020-04-02 perl v5.30.0