Re: accessing template variables in perl code
Stuart A Johnston <[email protected]> Fri, 08 Nov 2013 10:05:16 -0700
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
You could wrap your function in a closure over the name of the template
at the time you call process:
my $template = 'template/name';
$tt->process($template, { get_func => sub { get_params($template) } });
Er, then again couldn't you just retrieve your data before you call process?
On 11/08/2013 09:54 AM, Dave Howorth wrote:
> I expect my brain is fried and I'm doing it all wrong, but I'd
> appreciate advice about how to access template variables in perl code.
>
> I have a perl function that retrieves some data and returns it. I've put
> the function in the stash so I can call it in a template. It needs to
> decide what data to retrieve based on the name of the template, among
> other things. Is there a way it can access the template.name directly,
> to avoid having to pass the value as an argument every time?
>
> Or a better way to approach the problem?
>
> Thanks, Dave
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>