On Mon, 13 Nov 2000, you wrote:

> If you want to get more clever still, you can write a plugin which can
> make callbacks into TT to process other templates.
> 
>     package MyPlugin;
>     use base qw( Template::Plugin );
> 
>     sub new {
>       my ($class, $context, $data) = @_;
>       foreach my $item (@$data) {
>           $item = do_something_very_clever_with($item);
>           $context->include('table_row', { item => $item });
>       }
>       return 1;
>     }
> 
> meanwhile, in a template...
> 
>     [% USE MyPlugin([ 'foo', 'bar', 'baz' ]) %]
> 
>     [% BLOCK table_row %]
>        <tr><td>[% item.field1 %]</td><td>[% item.field2 %]</td></tr>
>     [% END %}
> 
> As this should hopefully illustrate, you can call Perl code from
> within templates and pass data to and fro.  You can also process
> template components from within Perl code, if you really want to, but
> still define them in the template where they should be (out there in
> look-and-feel land) rather than have them hidden away in Perl code
> (functionality corner).


ooh that looks like the babe.

I liek that one.

The bunch a crap scripts I have are supposed to in some way represent a
live auction site and allow different templates to sit on common
functioanlity fo rdifferent sites .. and that looks like it would do
better than my current batch .. mmm  objects ;-)

cheers

I'll post a url or two when i get a bit further on with it.

ta muchly

-- 
Robin Szemeti

The box said "requires windows 95 or better"
So I installed Linux!

Reply via email to