suppressed is rumored to have written:
> I recommend you flatten your structure before passing it to
> HTML::Template. Instead of building loops within loops, pass a
> 'depth' parameter and use that to build your HTML. There are, of
> course, other ways to do it, but I've found this works well and is
> easy to maintain.
How would you recommend flattening the structure to allow for embedded X
within X (where X is a table, UL, OL, etc)? I can think of translating
this:
$template->param(
sub => [
{
title => 'foo',
url => 'foo.html',
sub => [
{
title => 'foo-1',
url => 'foo-1.html',
},
]
}
]
);
to something like this....
$template->param(
stuff => [
{
openlevel => 1,
},
{
title => 'foo',
url => 'foo.html',
},
{
openlevel => 1,
},
{
title => 'foo-1',
url => 'foo-1.html',
},
{
closelevel => 1,
},
{
closelevel => 1,
}
]
);
Which could possibly be collapsed to ...
$template->param(
stuff => [
{
openlevel => 1,
title => 'foo',
url => 'foo.html',
},
{
openlevel => 1,
title => 'foo-1',
url => 'foo-1.html',
closelevel => 1,
},
{
closelevel => 1,
}
]
);
Is that what you were thinking of? I guess that this could then work in a
single template. I would probably do something more like this:
$template->param(stuff => flattenstructure($structure));
to try to automate / reuse it, but I think that may work.
Thanks for the alternate perspective.
Brian
----
Brian T. Wightman
suppressed
414.524.4025
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.