[rt-users] Template help REALLY required

Guillaume Perréal perreal at lyon.cemagref.fr
Mon Feb 16 17:46:14 EST 2004


Lederer, Damien a écrit :

>[snip]
>	===Create-Ticket: approval
>	{
>	   ... Lookup code...
>	   my @admins;
>	   push (@admins, "supervisor's email address");
>	}
>	AdminCc: {join ("\nAdminCc: ", at admins) }
>
>
>The example template does something extremely similar to this
>(http://www.bestpractical.com/rt/docs/3.0/appendix5-approvals.txt).  The
>example populates an array called "@admins" which is used later to assign to
>the "AdminCc:" section of the template.  However this does not work for
>me...  the value of "@admins" is NOT passed through... it just turns out
>blank.
>
>I asked this question before, but no answers were forthcoming.  Does anybody
>know how to resolve this?  Has anybody used variables/arrays in their
>templates in this manner?  Can anybody confirm/deny whether this works?  Am
>I asking the wrong mailing list?  Should I ask rt-devel?
>  
>
Each template code block corresponds is translated into a real Perl 
block. So I think your problem may be related to using "my @admins" 
between braces: the list @admins is syntaxically scoped to the frist 
block and thus is out of scope of the second block.

You can either try to use only one block :

{
   ... Lookup code...
   my @admins;
   push (@admins, "supervisor's email address");
   $OUT = map "\nAdminCc: $_", @admins;
}

(see Text::Template man page for usage of the $OUT variable).

Or omit the my() statement :

{
   ... Lookup code...
   @admins = (); # Even this can be facultative, depending of leading code
   push (@admins, "supervisor's email address");
}
AdminCc: {join ("\nAdminCc: ", at admins) }

-- 
Guillaume Perréal.

Responsable informatique,
Cemagref, groupement de Lyon,
France.

Tél: (+33) 4.72.20.87.87.
Fax: (+33) 4.78.47.78.75.
Site: http://www.lyon.cemagref.fr/





More information about the rt-users mailing list