in reply to Template Toolkit DEFAULT for null hash value

That approach works fine for me. Perhaps something is awry with your template?

#!/usr/bin/env perl use strict; use warnings; use Test::More; use Template; my $text = q#[% DEFAULT element.email = 'email' element.price = '0' %] email: [% element.email %] price: [% element.price %] #; my $out = ''; my $tt = Template->new; $tt->process (\$text, {element => {price => 10}}, \$out); like ($out, qr/email: email/, 'Default email used'); like ($out, qr/price: 10/, 'Non-default price used'); done_testing;

Replies are listed 'Best First'.
Re^2: Template Toolkit DEFAULT for null hash value
by epoch1 (Acolyte) on May 08, 2016 at 15:25 UTC
    Thanks Hippo, Yes it's odd. I'm using element.foo || 'bar' at the moment as a workaround until I have more time to investigate.