Catman...mplate(3pm)
πΈ Catmandu::Exporter::Template πΈ
okay bestie, welcome to Catmandu::Exporter::Template from the User Contributed Perl Documentation, it's a TT2 Template exporter in Catmandu style and it's literally so iconic π
β¨ SYNOPSIS β¨
first up, from the command line, she's serving:
# 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>
and now from perl π«Ά
# 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. and if you are new to Catmandu see Catmandu::Tutorial β no cap, go read it, it's giving starter pack energy π
π CONFIGURATION π
templateβ Required. Must contain path to the template. like, you literally cannot skip this one bestie πxmlβ Optional. Value:0or1. Prepends xml header to the template. tiny flag, big glow-up β¨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. yes, all of them, she's flexible like that π¦
π SEE ALSO π
Catmandu::ExporterTemplate
and that's the whole vibe check, periodt π β¨
this page is perl v5.36.0, dated 2022-09-27, and it came to you straight from the User Contributed Perl Documentation. mwah, go export something cute ππ¦π
π¦ where this page comes from
- ubuntu noble: libcatmandu-template-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-template-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-template-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms