building TT hash dynamically

"Roland Philibert" <rphilibert-UvF+vpO7X/[email protected]> Mon, 14 May 2012 09:16:56 +0100
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
HI all,

 

Am using TT as part of a catalyst application and am fairly new to TT, so hope the question is smart enough:

How can I dynamically build a TT hash? I am basically re-ordering database information in a sorted hash, so it can be displayed/rendered quicker but I need to add keys dynamically to the hash, and I am failing to do that.

Eg:

 

[% FOREACH sowcol IN sowreq -%]

                [% FOREACH sowipspec IN sowcol.sowipspecs -%]

                                [% spec = sowipspec.fipspecnb.ipspecnb ;

                                                arr.ipspecs.push({

                                                                $spec = [ {

                                                                                               nb = sowipspec.fipspecnb.ipspecnb,

                                                                               }]

                                                })

                                %]   à this works fine

                                [% FOREACH feview IN feviews -%]                                                         

                                                [% spec = sowipspec.fipspecnb.ipspecnb ;

                                                   arr.ipspecs.spec.push({                                                                              

                                                                                                                feviews = [ {

                                                                                                                                                type = feview.viewtype,

                                                                                                                                    }          

                                                                                                                ]

                                                                                                                                

                                                                                                })

                                                %] àThis does not work when wanting to add new key "feview".

                                [% END %]                                           

                [% END %]

[% END %]

 

Any help greatly appreciated.

Thanks

Roland

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 2XT. Registered in England No. 06570543.

This e-mail and any attachments contain confidential information and are solely for the review and use of the intended recipient. If you have received this e-mail in error, please notify the sender and destroy this e-mail and any copies.

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates