in reply to Template Toolkit, Default and Zero

Quoting from the Template::Manual::Directives perldoc page on the DEFAULT directive:-

The DEFAULT directive is similar to SET but only updates variables that are currently undefined or have no "true" value (in the Perl sense).

The following seems to work though:-

[% UNLESS n.defined && n.length; n = 1; END %]

Replies are listed 'Best First'.
Re^2: Template Toolkit, Default and Zero
by marvell (Pilgrim) on Aug 30, 2006 at 13:31 UTC

    Though not required, could this be turned into a MACRO?

    --
    Steve Marvell

Re^2: Template Toolkit, Default and Zero
by marvell (Pilgrim) on Aug 30, 2006 at 13:23 UTC

    That worked nothing less that perfectly as a replacement for DEFAULT. Thanks.

    --
    Steve Marvell