On Wednesday, August 25, 2004 at 16:32, erob wrote:
> Sorry for being unclear about the real problem..
> To recap, it's quite difficult to manage multiple variables in the same
> template (bad idea).

Can you give us at least an example why you have to "manage multiple
variables"? I really don't understand what exactly the problem is, so
it's even harder to give advice.

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

This is the same problem as with Perl's "my" and "local" variables.
You should use private variables (declared with "my") whenever
possible and refrain from using variables in a larger scope (declared
with "local" or "our") because this make your code more difficult to
maintain and more susceptible to errors. The same holds true for
templates: if you use INCLUDE you don't have to worry about nasty
side-effects.

> 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);
> }

Why don't you move your PROCESS and INCLUDE statements to your
templates? It seems more natural to me to handle all the output
formatting in the templates.

You said earlier:
> The drawback is that every content/feature need
> a separate template to be wrapped over to the site layout.

Why is this a drawback? I would even encourage using different
template files for different contents. This way you are able to
create modules and small reusable blocks that are easier to understand
and maintain.

Best regards,
Axel


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to