Gossamer Forum
Home : General : Perl Programming :

HTML::Template to GT::Template

Quote Reply
HTML::Template to GT::Template
I wonder if anyone here could help me to covert parser from HTML::Template to GT::Template
i now only able to do a single string replacement. while has difficulty in loop.

the orginal code is
sub display_cart {
my ($cgi, $session) = @_;
# getting the cart's contents
my $cart = $session->param("CART") || [];
my $total_price = 0;
my $RV = qq~<table><tr><th>Title</th><th>Price</th><th>Quantity</th></tr>~;
if ( $cart ) {
my $idx = 0;
for my $product ( @{$cart} ) { $idx++;
#$total_price += $product->{price};
$subtotal = ($product->{price})*($product->{quantity});
$total_price += $subtotal;
# my $idx = 0;
$RV .= qq~<tr><td>$product->{name}</td><td>$product->{price} ($idx++ $idx )</td><td>$subtotal----$product->{quantity}</td></tr>~;
}
} else {
$RV .= qq~
<tr>
<td colspan="2">There are no items in your cart
yet</td>
</tr>~;
}
$RV .= qq~
<tr>
<td><b>Total Price:::</b></td>
<td><b>$total_price></b></td>
</tr></table>~;
return $RV;

}
Subject Author Views Date
Thread HTML::Template to GT::Template courierb 12753 Oct 8, 2004, 8:56 AM
Thread Re: [courierb] HTML::Template to GT::Template
courierb 12570 Oct 8, 2004, 8:58 AM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 12518 Oct 8, 2004, 10:52 AM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 12522 Oct 8, 2004, 11:14 AM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 12506 Oct 8, 2004, 2:47 PM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 12541 Oct 8, 2004, 5:13 PM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 12492 Oct 8, 2004, 8:35 PM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 12521 Oct 10, 2004, 3:41 AM
Post Re: [courierb] HTML::Template to GT::Template
Chaz 12464 Oct 10, 2004, 11:26 AM
Thread Re: [courierb] HTML::Template to GT::Template
webmaster33 12430 Oct 20, 2004, 2:47 PM
Thread Re: [webmaster33] HTML::Template to GT::Template
Chaz 12427 Oct 21, 2004, 7:30 AM
Thread Re: [Chaz] HTML::Template to GT::Template
webmaster33 12538 Oct 22, 2004, 5:25 AM
Thread Re: [webmaster33] HTML::Template to GT::Template
Chaz 12378 Oct 22, 2004, 7:38 AM
Thread Re: [Chaz] HTML::Template to GT::Template
webmaster33 12476 Oct 22, 2004, 12:09 PM
Post Re: [webmaster33] HTML::Template to GT::Template
Chaz 12364 Oct 22, 2004, 12:26 PM
Post Re: [webmaster33] HTML::Template to GT::Template
Andy 12422 Oct 23, 2004, 3:00 AM