Re: [Templates] properly accessing variables and content processing with TT2
[prev]
[thread]
[next]
[Date index for 2004/08/24]
On Tue, Aug 24, 2004 at 02:12:28PM -0400, Perrin Harkins wrote:
> On Mon, 2004-08-23 at 14:27, erob wrote:
> > For the sake of simplicity, I created a main template, called
> > "main-perl.tt" which is simply a big [% RAWPERL %] ... [% END %]
> > directive.
>
> That's usually a bad idea, but you probably know that.
>
> > However, for some reasons, handling exceptions of the following
> > form does not gives back what I want :
> >
> > if ($stash->get('foo') {
> > $output .= "more foo";
> > $output .= $context->process('foo.tt');
> > }
> >
> > # XXX Cannot get 'blurb' because 'foo' still exists..
>
> I have no idea what you mean by this. Can you try explaining it in more
> detail?
>
Consider this MVC scheme (although skipping the Model part):
#==============================================================#
# A Controller: from a mod_perl handler, Apache::Registry, etc #
# $output .= $context->process($template,$vars); #
# $r->print ($output); #
#==============================================================#
|
+------->#==================================#
# A View: #
# some $template acting as WRAPPER #
# to the real template (index.tt): #
# [% WRAPPER 'index.tt' %] #
# [% PROCESS 'some_content' %] #
# [% END %] #
#==================================#
|
|
+-----------------------------------+
|
|
|
+----->#===============#
# index.tt #
#===============#
So this is basically the logic behind it.
It is extensible, and the stash problem disappear because variables
dont clobber each others, as when forwarding all the content to the same
template. In other words, there's no precedences problem, because
variables are kept in their own template.
The drawback is that every content/feature need
a separate template to be wrapped over to the site layout.
Feel free to improve this (design or whatever) if you feel like it ;)
> - Perrin
Best regards,
Etienne
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
(message missing)
|