Re: [Templates] properly accessing variables and content processing with TT2

[prev] [thread] [next] [Date index for 2004/08/25]

From: erob
Subject: Re: [Templates] properly accessing variables and content processing with TT2
Date: 14:32 on 25 Aug 2004
On Tue, Aug 24, 2004 at 05:09:48PM -0400, Perrin Harkins wrote:

> You aren't actually telling us what problem you had here.

Sorry for being unclear about the real problem..
To recap, it's quite difficult to manage multiple variables in the same
template (bad idea).

As a workaround, I suggested the idea of implementing some kind of
$stash->unset() method in order to avoid precedences problems, for instance,
when dealing with multiples variables inside the same template. 
(again, still not a good idea :) 

> Maybe you were looking for INCLUDE instead of PROCESS?  With INCLUDE,
> the stash is not clobbered by variables set inside of templates that are
> run.

How about using PROCESS to update variables which really need processing
and leaving INCLUDE for the less important stuff ? 

sub handler {
	my $r = shift;
	my $output;
	my $stash = $CONTEXT->stash();			# get the stash,
	$stash->set('updateme', \$var);			# some content, 
	$output .= $CONTEXT->include('header');	# does not need updating,
	$output .= $CONTEXT->process('content');# but this does,
	$output .= $CONTEXT->include('footer');	# and this doesnt.
	$r->print ($output);
}

> - Perrin

Best regards,
Etienne

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

Re: [Templates] properly accessing variables and content processing with TT2
erob 14:32 on 25 Aug 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52