Hello,

I am getting few columns from my table.

itemid, will not be blank
itemprop_comment, may be blank
item_prop, will not be blank

I am thinking to store it in an hash as follows...

using a loop...

while ($record = $record_rs->next ()){
    my $itemid = $record->get_column("itemid");
    my $itemdetail = 
$record->get_column("itemprop_comment")."\|".$record->get_column("item_prop");
    $tmp_hash->{$itemid} = "$itemdetail";
};

now send it to tt

$vars = {
    itemname => $it_nam,
    itemlist => $tmp_hash
};


now sending to my tt template


my $tt = Template->new({
    INCLUDE_PATH => $templatepath,
    });
$tt->process($mytt_template,$vars)|| die $tt->error();



I am confused as to, how to get the values out in the tt.....


        [%- FOREACH itemid IN itemlist.keys.sort -%]
            itemid=[% itemid %] item_prop_comment=[%- 
itemlist.$itemid.replace('\|.*$','') -%]  item_property=[%- 
itemlist.$itemid.replace('.*\|','') -%] <br>
        [% END -%]




first of all will this work? secondly what if there is some pipe character in 
the Item property or comments?

Can I not have these two columns as array elements to the value of hash key? 
and how can I handle that array value (of hash key element) in the tt template? 
pl advice.

I mean if    $tmp_hash->{$itemid} = @my_array;
 then itemlist.$itemid will be an array namely @my_array in tt and how will i 
get items from this array in my tt template....


ty.


_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to