Clinton Gormley wrote: > Yeah, I wasn't expecting it to happen for TT2 - more of a request for > TT3 really
Hi Clinton, Short answer: Yes, I've been burned by this myself. Long answer follows... > Although, it could be implemented in such as way that two new error > types eg 'file_missing' and 'parse_error' could both inherit from > 'file', which would let the old version continue working. That's a possibility. In fact TT2 already supports dotted exception types so we could throw file.syntax and file.missing exceptions and they would both be caught by existing [% CATCH file %] handlers. There would be little or no breakage there, while allowing the likes of you and I to have more specific [% CATCH file.syntax %] handlers. However, I've got a nasty feeling that making that change is going to be No Fun At All[tm] due the profound mess that is Template::Provider and the brain-dead way in which I decided to implement error handling at that low level. I've completely re-written all that code for TT3 so that the provider (now called Template::Templates) throws its own exceptions. As it currently stands it throws a 'parse' error to differentiate from a 'file' error, but it might make more sense to use a dotted exception like file.syntax. There's also a half-way house version of TT2/3, currently living in the Template::TT2 namespace. It's not officially released on CPAN yet and it's a developer-version or two behind the current official TT2 (it was cloned last October but has lain dormant for a few months due to heavy $work), but it's there in the TT subversion repository if you or anyone else wants to have a play with it. The Changes file is a good place to start. http://template-toolkit.org/svnweb/Template-TT2/browse/trunk Template::TT2 is a 99% faithful implementation of the TT2 language, using the same grammar and parser engine, but re-factored and re-written to fit in with the Badger-based TT3 architecture. The main purpose is to be a legacy version that people relying on TT2 (quirks and all) can continue to use after TT3 is released - I don't want people coming after me with sticks because I released a new version of the Template module that broke their web site. I also used the opportunity to clean up some of the worst bits of cruft and generally make things a bit nicer behind the scenes. In particular, it cleans up this whole error handling mess. In fact, the 1% incompatibility with TT2 (at the template language level) is that the parser throws 'parse' errors instead of 'file' errors and I know that's going to break templates, including some of my own. But if I changed that to throw file.parse (or file.syntax) errors instead then I *think* we're back at 100%. I'm not sure if that'll keep all the people happy all the time, but if it reduces the number of people coming after me with sticks then it's a good start :-) Cheers A _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
