On Wed, Jul 10, 2002 at 12:00:51PM +0100, Mark Fowler wrote: > This is getting all very complicated - you're requiring the template > author (even if it is you) to know how the internals of your objects > work. I'd be tempted to say at this point that you really should be doing > it in Perl. > Of course, you're more than welcome to disagree :-)
And, of course, disagree I shall :) You're not really needing them to know any internals - you're just needing them to know relationships - which they already know anyway: Let's take a video example. We have a Video class, and a Star class. The show/video template will be passed a video object, and show/star a star object. The template author knows that to get a star's name they do: [% star.name %]. And that they have [% video.runlength %], [% video.certificate %] etc. To get a video's title is slightly more complex: you have [% video.title.name %] and [% video.title.format %] The template authors know all this, and use it well. They also know that there's a relationship between videos and stars, so they can do: [% FOREACH video = star.appears_in %] <li>[% video.title.name %] [% END %] All I'm wanting is to extend this so that they can print the films in alphabetical order: [% FOREACH video = star.appears_in.sort(title.name) %] <li>[% video.title.name %] [% END %] They don't need to know anything extra here that they don't already know. They just long for a search that can work 'at a distance' like this ;) > I'd write a simple wrapping plugin at this point that has methods like you > describe adding to the actual class itself. This way when the underlying > module changes your templates won't need to be rewritten. Hmmm. Plugins. I really need to learn more about them. I don't really use plugins ... not for things like this anyway... Tony
