Jens Rehsack wrote:
>> [% my idx = mylist.firstidx( \funcs.numeq, 4, [ 1, 6, 9, 3, 4, 2, 5 ] ); %]
>
> That works - great. I didn't know that TT2 can do that.
Glad to hear.
>> As an alternative, you can evaluate a block by passing the block name to
>> the plugin and using the context to process the block.
>
> With name of block you mean sth. like "MyPkg::myFunc" - and I resolve that
> in plugin using *{$_[0]}{CODE}? Or do you mean I can access the macros
> defined in the template from plugin?
No, I meant you'd do something like:
[% BLOCK blockfoo %][% a >= b %][% END %]
OR:
[% BLOCK blockfoo %][% PERL %]
print $stash->get( 'a' ) ge $stash->get( 'b' );
[% END %][% END %]
Then you call
[% item = mylist.bsearch( 'blockfoo', "abc", [ "bar", "baz", "goo" ] ); %]
Then in the plugin you'd probably make a wrapper function like this that you'd
use:
my $doge = sub{
$stash->set('a', $_[0]);
$stash->set('b', $_[1]);
return $context->process($opt->{tt_block});
};
There are probably some details to work out there, but that's an overview of
what I was thinking.
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates