Subbu Meiyappan wrote:
if (!passed_in_MY_BOOL_D1){
MY_BOOL_D1 = 1
}
does'nt quite cut it, because if I pass in a '0', the if evaluates to
true and MY_BOOL_D1 gets 1. So the value that gets assigned is the
inverse of what is passed in.
Hi,
Not really sure what you are saying here. What I said is correct, though. Since
you passed in 0, TT will think that it is getting a perl false value, and as
such will use the default value, which in this case happens to be 1.
I'd suggest using an IF/SET statement instead of DEFAULT when dealing with
booleans/ints. (Or whenever you want to pass a variable with a zero or empty
string value.)
So instead of:
[% DEFAULT
MY_BOOL_D0 = 0,
MY_BOOL_D1 = 1,
MY_INT_D10 = 10 %]
Something like:
[% IF !MY_BOOL_D0.defined();
SET MY_BOOL_D0 = 0;
END ;
%]
[% IF !MY_BOOL_D1.defined();
SET MY_BOOL_D1 = 1;
END ;
%]
[% IF !MY_INT_D10.defined();
SET MY_INT_D10 = 10;
END ;
%]
It's longer but should get the job done.
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates