I'm not using the latest version of TT, so maybe this is already implemented.

The idea is to allow template authors define lexically scoped
variables just as in perl.

I.e.:

[% my foo = ...expression... %]

would generate:

  my $foo = ...expression...

instead of:

  $stash->set(['foo', 0], ...expression...)

And a simple get on 'foo' would be replaced with $foo in the compiled
code. A more complex get like [% foo.attr1.attr2 %] would still have
to be resolved with something like $stash->get(), but you could begin
with the value of $foo, i.e.:

  Template::lexical_get($foo, ['attr1', 0, 'attr2', 0])

Besides being more efficient, having lexicals would allow template
authors to avoid name clashes in sub-templates without the caller
having to invoke the sub-template with PROCESS.

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to