Re: [Templates] hashes and loops

[prev] [thread] [next] [Date index for 2004/10/19]

From: Simon Wistow
Subject: Re: [Templates] hashes and loops
Date: 20:54 on 19 Oct 2004
On Tue, Oct 19, 2004 at 03:13:17PM -0400, Darren Chamberlain said:
> You'll need to change the push to be:
> 
>   push @emails, {
>       from => "fred",
>       to => "wilma",
>       subj => $subj,
>       date => "today"
>   };
> 
> I.e., push a hashref instead of an arrayref of a hashref.  That should
> get you going...


On a style note you might also think about changing it to

	my $subj = get_email_subj($ref[0]);
	
	push @emails, {
       from => "fred",
       to => "wilma",
       subj => $subj,
       date => "today",
	   file => $ref[0],
   };



and then in the template where you currently have

	<td>[% email.subj %]</td>

do this instead

	<td>
		<a href="crm.pl?action=show_email&file=[% email.file %]">
			[ % email.subj %]
		</a>
	</td>

Since that way you have better seperating of concerns.

It might make things easier in the future if you want to do a 
redesign, generate the content in a different format (XML, Excel, WML, 
PDF etc etc) or even if you decide to move the app to mod_perl or change 
the name of the cgi from crm.pl to damn_customers.pl ;)

Simon


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

[Templates] hashes and loops
Brandon Hall 19:03 on 19 Oct 2004

Re: [Templates] hashes and loops
Sean Kellogg 19:10 on 19 Oct 2004

Re: [Templates] hashes and loops
Brandon Hall 06:51 on 21 Oct 2004

Re: [Templates] hashes and loops
Michael 13:44 on 21 Oct 2004

Re: [Templates] hashes and loops
Michael 13:58 on 21 Oct 2004

Re: [Templates] hashes and loops
Dave Cash 13:47 on 21 Oct 2004

Re: [Templates] hashes and loops
Sean McAfee 14:34 on 21 Oct 2004

Re: [Templates] hashes and loops
Trond Michelsen 14:44 on 21 Oct 2004

Re: [Templates] hashes and loops
Mark Mills 15:22 on 21 Oct 2004

Re: [Templates] hashes and loops
Darren Chamberlain 19:13 on 19 Oct 2004

Re: [Templates] hashes and loops
Simon Wistow 20:54 on 19 Oct 2004

Re: [Templates] hashes and loops
Brandon Hall 23:56 on 21 Oct 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52