[Templates] Can a template discover if a block is defined?
Derrek Long
Derrek.Long@ticketmaster.com
Fri, 22 Dec 2006 10:42:24 -0800
> You can do a TRY block. But you must catch the error.
Yes, the try catch is perfect.
I had forgotten TT offers this.
Thanks much,
-Derrek
-----Original Message-----
From: Clinton Gormley [mailto:clint@traveljury.com]
Sent: Friday, December 22, 2006 12:43 AM
To: Derrek Long
Cc: 'templates@template-toolkit.org'
Subject: Re: [Templates] Can a template discover if a block is defined?
You can do a TRY block. But you must catch the error.
TRY;
PROCESS FOO;
CATCH;
'';
END;
>
>
>
>
> Template 2 (bar.tt):
>
> [% PROCESS foo IF foo.defined # in other words if the block foo exists
> %]
>
>
>
> In this case TT will not compile if the BLOCK foo doesn't exist in
> foo.tt. Is there a way in TT code to prevent that compilation error?
>
>
>
> Thanks,
>
> -Derrek
>
>