On Fri, Aug 03, 2001 at 07:18:20PM -0500, Andy Levine wrote:
> So, I hoped I could ask the template engine, "Give me a list of values you
> need", it would return "Sure, (ip, hostname)" then I could get JUST the ones
> I wanted. Then I would, process(template, list); and all would be well.

For v3 I thought that there should be some way to pre-define a set of 
variables for a template and/or block.  Not sure of the syntax, but maybe
something like:

[% TEMPLATE
     vars = { foo, bar, baz = 'specific baz value' }
%]

or

[% BLOCK vars = { wiz, waz } %]
   ...
[% END %]

This would create an isolated stash with those and only those named 
variables defined with their current values or specific values provided.

In the first example, this would also be a clue to the page cache for it
to determine if a cached page is valid (e.g. none of the critical vars
have changed value).  In either example, it allows a template or block
to create a separate subset of the stash with pre-fetched values which 
can then be accessed more optimally.  Another benefit is that any variable
updates within such an isolated stash will have no side-effects outside
of the template or block.

The 64 kilobyte question is "Can we, and should we automatically determine
the variable usage in a template?".

I'm not sure about the answer to that.  Yes, we can keep track of all 
static variables get/set in a template but we can't catch everything
due to the dynamic evaluation of variables.  e.g.

    [% foo.$var %]

In that case, I guess we say "Caveat Hacker" and accept the fact that 
the variable usage can't be determined accurately and the page can't be 
cached, etc., without further specific clues, e.g. as above.

Does that sound reasonable?


A



Reply via email to