I've had the same desire for letting the template give
hints/instructions/info/parts to the caller. A common one for me is the Subject
line in email. The caller needs the subject for email headers, but this value
is content. A ready example is multi-lingual versions of the same message:
# hello-world-en.tt
[% SUB writeback.subject = 'Hello world' %]
message body here...
# hello-world-es.tt
[% SET writeback.subject = 'Hola, mundo' %]
el cuerpo del mensaje aquĆ...
$file = sprintf('hello-world-%s.tt', $lang);
$vars{writeback}={};
$tt->process($file, \%vars, \$content);
$email->send(subject => $vars{writeback}->{subject}, content => $content);
I have notes on more elaborate situations that would like two-way
communication, but none have become important enough to build or are short
enough to add to this thread that appears to be fully adressed before I wrote
this message. :)
---
Rodney Broom
----- Original Message -----
From: "Perrin Harkins" <[email protected]>
To: "E R" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, January 21, 2010 15:50
Subject: Re: [Templates] passing information back from templates
> On Thu, Jan 21, 2010 at 5:17 PM, E R <[email protected]> wrote:
>> When using a simple hash for the template variables object, it doesn't
>> seem that a template can modify it, e.g.
>
> Is this a physics experiment? The data changes when it is observed?
>
> Seriously, it sounds like you're trying to do non-display programming
> in TT instead of in Perl, which is usually a bad idea.
>
> - Perrin
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates