The Artima Developer Community
Sponsored Link

Java Buzz Forum
Simple arrays in HTML::Template

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Simple arrays in HTML::Template Posted: May 14, 2004 8:05 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Simple arrays in HTML::Template
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement
Are you an HTML::Template user? Can you tell me how to display simple scalars (versus hashrefs) in an array? To put it more concretely, I have something like the following in Template Toolkit:
my @names = qw( John Paul Ringo );
my $template = Template->new();
$template->process( \*DATA, { names => \@names } );
__DATA__
You listed the following names:
[% FOREACH name = names %]
  * [% name %]
[% END %]

Is there an equivalent in HTML::Template? Because from looking over the docs it appears I need to move the data into hashrefs within the array, which is really annoying if you're trying to build a framework that works on multiple templating systems:

my @names = ( { name => 'John' },
              { name => 'Paul' },
              { name => 'Ringo' } );
my $template = HTML::Template->new( filehandle => *DATA  );
$template->param( names => \@names );
print $template->output();
__DATA__
You listed the following names:
<TMPL_LOOP NAME="names">
  * <TMPL_VAR NAME="name">
</TMPL_LOOP>

Read: Simple arrays in HTML::Template

Topic: Finally code folding in Eclipse! Previous Topic   Next Topic Topic: [May 4, 2004 12:38 PDT] 8 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use