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 9529 Oct 8, 2004, 8:56 AM
Thread Re: [courierb] HTML::Template to GT::Template
courierb 9430 Oct 8, 2004, 8:58 AM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 9377 Oct 8, 2004, 10:52 AM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 9382 Oct 8, 2004, 11:14 AM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 9359 Oct 8, 2004, 2:47 PM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 9400 Oct 8, 2004, 5:13 PM
Thread Re: [courierb] HTML::Template to GT::Template
Chaz 9352 Oct 8, 2004, 8:35 PM
Thread Re: [Chaz] HTML::Template to GT::Template
courierb 9380 Oct 10, 2004, 3:41 AM
Post Re: [courierb] HTML::Template to GT::Template
Chaz 9332 Oct 10, 2004, 11:26 AM
Thread Re: [courierb] HTML::Template to GT::Template
webmaster33 9300 Oct 20, 2004, 2:47 PM
Thread Re: [webmaster33] HTML::Template to GT::Template
Chaz 9288 Oct 21, 2004, 7:30 AM
Thread Re: [Chaz] HTML::Template to GT::Template
webmaster33 9400 Oct 22, 2004, 5:25 AM
Thread Re: [webmaster33] HTML::Template to GT::Template
Chaz 9246 Oct 22, 2004, 7:38 AM
Thread Re: [Chaz] HTML::Template to GT::Template
webmaster33 9329 Oct 22, 2004, 12:09 PM
Post Re: [webmaster33] HTML::Template to GT::Template
Chaz 9232 Oct 22, 2004, 12:26 PM
Post Re: [webmaster33] HTML::Template to GT::Template
Andy 9292 Oct 23, 2004, 3:00 AM