On Jul 25, 2007, at 8:36 PM, Bill Moseley wrote:

On Wed, Jul 25, 2007 at 01:30:46PM -0700, Matisse Enzer wrote:
(re-posted because I stoopidly left out the Subject on the prior
posting. I apologize.)

How do get Template Toolkit to throw an exception if it encounters a
call to a non-existent method?

You want it globally, or just in some cases?

    DEBUG_UNDEF

Otherwise, I'd test for values and use THROW if I didn't like what I
got.


So I have tried the DEBUG_UNDEF approach, but, I now find that it doesn't do what I want.

With DEBUG_UNDEF this template produces an error if someMethod() exists but
returns and empty list:

    [% FOREACH thing IN object.someMethod %]
        [% thing %]
    [% END %]

What I want is an error only if $object is undef, or if there is no someMethod() defined, and I want this behavior globally.

What's the best practice for achieving this?

-M

------------------------------------
Matisse Enzer
[EMAIL PROTECTED]




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

Reply via email to