Perl Programming Build a Perl RSS Aggregator with Templating Tools |
If we're going to get anywhere with our RSS example, we'll need to loop over a series of items--the stories in our newsreel. Thankfully, HTML::Template provides the <TMPL_LOOP> pseudotag for treating a variable as an array. For instance, the following code: <ul> when provided the appropriate data structure, loops over the items in the STORIES array reference and produces output like so: <ul>
</ul> The trick is that the array reference needs to contain an array of hashes, and each hash provides the appropriate variable names: $template->param(STORIES => [
blog comments powered by Disqus |