Brad Bowman wrote:
> the vfield code also needs access to the template context
[...]
> The only other feature that seemed to fit the syntax and has
> context access is a plugin.
Hi Brad,
Yes, you probably want to code a plugin for this. When you USE the plugin
you get a reference to the context. You can either return an object which
saves the context internally, or a closure like this:
package Brads::Plugin::vfield;
use base 'Template::Plugin';
sub new {
my ($class, $context) = @_;
sub {
my $stash = $context->stash();
my $fq_vfield = $stash->get('fq_vfield');
my $line = $stash->get('line');
# ... do stuff
return "$fq_vfield @ $line";
}
}
Then:
[% USE vfield %] # you can do this in a PRE_PROCESS template/block
[% vfield('test') %]
HTH
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates