How to execute template tooklit script?

Viewed 62

I would like to execute a template toolkit script with some dummy data in order to quickly test functionality. For example, an script that adds a date into an excel.

[%- MODE=xlsx %]
[%-
    X = XLSX;
    X.newWorksheet('My Report');
    USE date;
    # use current time and default format
    X.add(date.format)
    X.end()
    X.print();
-%]

Is it any interpreter or tool (installed or online) to execute this type of scripts? I'm using Ubuntu 20.04.

1 Answers

The module installs the tpage command line tool.

$ cat greeting.tt
Hello, [% target %]!

$ tpage --define target=World greeting.tt
Hello, World!

Of course, you could also write a small Perl script.

use Template qw( );
my $tt = Template->new();
$tt->process('greeting.tt', {
   target => 'World',
})
   or die($tt->error());
Related