Catman...mplate(3pm)

πŸ“¦
version 0.14 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 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: 0 or 1. 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::Exporter
  • Template

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