On Mon, 2002-12-09 at 17:59, Gernot Homma wrote:
>
> i just took a look at the docs but i didn't get the clue. well, i know how
> to do something with the context and the stasth, but i just don't know how
> to specify the block, so when this block is called out from a template i
> have a reference to the object to which the method belongs.
How about defining all the blocks in a common template and then calling
that with the PRE_PROCESS directive ?
I use that method a lot for abstracting out all the common blocks I know
I want to use over and over again.
What you suggested in your first post can't be achieved with the block
mechanism and INCLUDE as far as I understand it. If you need access to
predefined variables, you should pass them as a reference to the
template. Off the top of my head, I would probably create a tmplprocess
method in MyPackage that would assemble a vars hash from the object data
and then call the process method of the template with the object
specific variables. Something like (untested):
sub tmplprocess {
my $self = shift;
my $myvar = $self->{ __myvar };
my $tmpl = 'template'; # Not sure where this comes from in your
# example
$self->{ __template }->process( $tmpl, { myvar => $myvar } );
}
Sorry, more than one way to do it there and I've rambled a bit. Hope you
can find something useful.
Simon.
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.ourshack.com/mailman/listinfo/templates