> -----Original Message-----
> From: darren chamberlain [mailto:[EMAIL PROTECTED] 
> Sent: 03 December 2003 18:07
> To: [EMAIL PROTECTED]
> Subject: Re: [Templates] Behavior of DEFAULT Directive
> 
> 
> * christopher <christopher at tokpela.com> [2003/12/03 09:40]:
> > This leaves no distinction between 0 and undef meaning you 
> can never 
> > turn off a default by number, you would always have to use literal 
> > strings like on/off.  Although the docs defer to Perl, is this the 
> > desired result or should the DEFAULT directive allow the value of 
> > zero?
> 
> This is the desired outcome.
> 
> You could pass some constants into your template:
> 
>   use Template;
>   my $template = Template->new(CONSTANTS => { TRUE => 1, 
> FALSE => 0 });
>   $template->process(\*DATA) or die $template->error();
> 
> And check against constants.TRUE and constants.FALSE instead 
> of simply testing truth.

Or you could simply use the defined vmethod

[% foo = '';
   IF foo.defined %]
Foo
[% END %]


S

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to