My lack of sleep is not helping me think clearly.

Macros are anonymous subs placed in the stash.  If I setup a library
of macros (say loaded in PRE_PROCESS) I assume that means each call to
process() must re-populate the stash with those macros.  If it was
possible, would there be a way to use the same initial stash for each
call to process(), and would that (premature optimization aside) help
speed at all?  I'm not sure how this could work with the macros
referencing the outer $stash, $context, and $output.

Where's that coffee?



> 
>     This is plain text
> 
>     [% MACRO my_macro( var ) BLOCK;
> 
>         "Var is '$var'\n";
>     END %]

>         eval { BLOCK: {
>             $output .=  "\nThis is plain text\n\n";
>     #line 0 "input file handle"
>             
>             # MACRO
>             $stash->set('my_macro', sub {
>                 my $output = '';
>                 my (%args, $params);
>                 $args{ 'var' } = shift;
>                 $params = shift;
>                 $params = { } unless ref($params) eq 'HASH';
>                 $params = { %args, %$params };
>             
>                 my $stash = $context->localise($params);
>                 eval {
>     #line 0 "input file handle"
>                     $output .=  ("Var is '" . $stash->get('var') . "'\n");
>                 };
>                 $stash = $context->delocalise();
>                 die $@ if $@;
>                 return $output;
>             });
>             
>             $output .=  "\n\n\n";



-- 
Bill Moseley
[EMAIL PROTECTED]


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

Reply via email to