Search code examples
perltemplate-toolkit

How can Perl's Template remove the whitespace following a directive?


I have the following template

[% DEFAULT label = 'null' %]
order: '[% order %]',
name:  '[% name %]',
product:'[% product %]',
label : '[% label %]'

which included on a template my.tt file

on Perl I have the following configuration :

my $template    = Template->new();
open(my $fh, '>:raw', \$report); 
$template->process('my.tt', \%data,$fh) or die $template->error();
print $report;

when i print $report i see on the first line -> new line then the info like below printed, how can i remove the new line char from the first line?

order: 'order1'
name: 'testname'
product: 'testproduct'
label: 'label1'

Solution

  • Simply use -%] instead of %].