Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: loop through a hash structure without knowing the hash keys?: msg#00025

lang.perl.modules.html-template

Subject: Re: loop through a hash structure without knowing the hash keys?


Well, I guess I should have explained the need of this
with a more solid real world use case.
Recently I am involved in a project using Krang, a CMS
system written in Perl that utilizes HTML::Template.
Now here is the thing, we are fairly new to the code
base, but in a few days of going through the code and
poking around the code, we were able to implement
quite a few new features for the client.

But our understanding of the system is still immature
and incomplete, and there are times the template var
is being set somewhere in the inheritance chain, and
we know a template can access a specific variable
(through incomplete doc and tmpl_if test), but there
is no way to know how to access the variable without
going through the code tracing out where and what is
sent to the template. And what if the documentation
misses talking about a var that is sent to the
template? No one you can find out unless you poke
around the code, but the process can be time consuming
as not all the templates are being set in one file
(due to OO).

I find it surprising that people expect problems can
be solved with documentation, or communication with
the frontend folks. In the real world, documentation
is never as complete as should, I mean, it's hard
enough to get some to comment their code! And in the
real world, you don't always start a project with code
that you have written as well. The need to be able to
introspect and access what is sent to the template
without having the perl code is a useful and
justifiable feature of any server-side scripting
framework.


- boon

--- "Webmaster Techcode.NET" <webmaster@xxxxxxxxxxxx>
wrote:

>
> ----- Original Message -----
> From: Boon Chew
>
> I want a way to quickly display all the info in a
> var - a Dumper output if you will. But more than
> that, like in some other server-side language, you
> can query the column lists (or hash keys) and loop
> through those and use a piece of generic code when
> all you intend to do is to display everything in the
> var.
>
> ----- Original Message -----
>
> I agree - something like Data::Dumper in
> HTML::Template context would be great.
>
> And you can also "you can query the column lists (or
> hash keys) and loop through those" in Perl just like
> in any other server-side language ...
>
> foreach(@array){
> print $_,"\n<br>";
> }
>
>
>
> ----- Original Message -----
> The tight coupling of knowledge between what's being
> sent from the perl code and the HTML can be avoided,
> that's the whole point of the design of the template
> module (vs Mason where you mingle Perl code with
> display code) right? It just seems ugly when I have
> to tell a designer to go look at the perl file to
> see what he is getting in the var. He should be
> able to find that out fro m some sensible
> constructs.
> ----- Original Message -----
>
> You missed the point ...
>
> I mean - designer shouldn't need to take a look at
> Perl code to figure out what you are outputing ...
> And "some sensible constructs" are documents that
> folow every project. Have you ever heared of terms
> like API or Interface? You and you designer need to
> agree on "Interface" - in your case the data he can
> use in the template ...
>
> Anyway - the quick and simple solution that just
> crossed my mind ;)
>
> Make something a rule - for each template - you
> could create a special variable. Say you can name it
> : "the_dump" or whatever.
> And simply dump via Data::Dumper all variables that
> you (plan) populate the template with - or send to
> template.
>
> Actualy - this could be made as part of
> HTML-Template ...
>
> Anyway - then your designer could just add <tmpl_var
> name="the_dump"> at the end of the template if he is
> not sure what data he can access.
>
> Of course - next thing he will complain is why in
> the hell he can't do a preview in Dreamweaver with
> test data already populated ...
>
> Cheers,
> Alex.
> N¬HYÞµé??X¬²?'²?Þu¼?¦[§??Ü?¨º
> Þ¦Øk¢è!???W¬~?é®?åzk¶?C£
å¡§m?éÞÀ@^Ç?­È^?§zØZ¶f¤zËj·!?x2¢êå¢â?ë±æ¬É«,º·â? a{?
å?,àHòÔ4¨m¶?ÿiÛ(±ÙÜ¢oÚv'ï­ûjYhr'ׯ:æ?rX??{f?צ¦V­zë®É??X§?X¬´{f?צ¦V­zë®Éb²Û,¢êÜyú+?éÞ¶m¦Ïÿ?+-²Ê.­Ç?¢¸?ë?+-³ùb²Ø§~?á¶imzjej×®±êì




__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe