Todd Rinaldo wrote:
> What we discovered we need to do is this
> defined fee && fee.defined('fi') && fee.fi.defined('fo') &&
> fee.fi.fo.defined('fum')
>
> To make things more dificult, the length of the nest isn't always the
> same. For instance, we might need to test if fee.fi.fo.fum.foo.bar is
> defined.
>
> My question: Is there any easy way to make a recursive block that can
> test if an unpredictably deep hash is defined?
Ok, I don't really have a good picture of your exact situation and you may have
already thought of this since it seems pretty simple. I'll throw it out there
anyway.
*) You might be able to simplify that .defined() stuff. You don't need to use
the defined test until the very last item:
[% IF a.b.c.d.e && a.b.c.d.e.defined('f') %]
*) If necessary, you could always use a WHILE statement to traverse through.
That in combination with the following could help.
*) You could also create a BLOCK that will output a value if your conditions
are true.
[% a = PROCESS my_test_block %]
[% IF a %]do stuff [% END %]
[% BLOCK my_test_block %]do test here that will output something if correct[%
END %]
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates