Discussion:
[htmltmpl] Data -> template (brain -> Perl)
Robert
2009-09-11 15:06:13 UTC
Permalink
I am using XML::Simple to get some "simple" XML data.

$template->param( DATA => sub {
for my $list ( @{ $data->{list} } ) {
print "<p>$list->{name}[0]</p><p>$list->{description}[0]</p>";
}
}
);

That prints the data to the template at the top...it doesn't go into the
DATA var. Do I need to do the for loop outside of the $template-param?

Bob
Brad Baxter
2009-09-11 15:12:57 UTC
Permalink
Bob,

You need to 'return' the data rather than 'print'ing it.

Brad
Post by Robert
I am using XML::Simple to get some "simple" XML data.
$template->param( DATA => sub {
           print "<p>$list->{name}[0]</p><p>$list->{description}[0]</p>";
       }
   }
);
That prints the data to the template at the top...it doesn't go into the
DATA var. Do I need to do the for loop outside of the $template-param?
Bob
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Html-template-users mailing list
https://lists.sourceforge.net/lists/listinfo/html-template-users
--
Brad Baxter
----------------------------------------------------------------------
Robert
2009-09-11 15:26:19 UTC
Permalink
Post by Brad Baxter
Bob,
You need to 'return' the data rather than 'print'ing it.
Brad
Yup, figured that out about 2 minutes after I posted. :-\

Bob
Sam Tregar
2009-09-11 15:24:22 UTC
Permalink
Post by Robert
I am using XML::Simple to get some "simple" XML data.
$template->param( DATA => sub {
print "<p>$list->{name}[0]</p><p>$list->{description}[0]</p>";
}
}
);
That prints the data to the template at the top...it doesn't go into the
DATA var. Do I need to do the for loop outside of the $template-param?
Don't print() the data, instead build up a string and return() it.

-sam

Loading...