DHTML(3pm)
π DHTML(3pm) β Data::TreeDumper::Renderer::DHTML π
okay so bestie, you found the User Contributed Perl Documentation page for the DHTML renderer, and honestly? it's giving "tiny module, huge main character energy." let's get into it π
β¨ NAME β¨
Data::TreeDumper::Renderer::DHTML β the DHTML renderer for Data::TreeDumper. that's it, that's the name, she's simple and she knows it π
πΈ SYNOPSIS πΈ
here's the whole vibe in one shot, no cap:
use Data::TreeDumper ;
#-------------------------------------------------------------------------------
my $style ;
my $body = DumpTree
(
GetData(), 'Data',
DISPLAY_ROOT_ADDRESS => 1,
DISPLAY_PERL_ADDRESS => 1,
DISPLAY_PERL_SIZE => 1,
RENDERER =>
{
NAME => 'DHTML',
STYLE => \$style,
BUTTON =>
{
COLLAPSE_EXPAND => 1,
SEARCH => 1,
},
},
) ;
print <<EOT;
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html>
<!--
Automatically generated by Perl and Data::TreeDumper::DHTML
-->
<head>
<title>Data</title>
$style
</head>
<body>
$body
<p>
<img src='http://www.w3.org/Icons/valid-xhtml10' alt='Valid HTML 4.01!' height="15" width='44' />
</p>
</body>
</html>
EOT
see how $style and $body get slurped right into the HTML? that's the whole trick. iconic behavior fr fr β¨
π¦ DESCRIPTION π¦
so basically: it's a simple DHTML renderer for Data::TreeDumper. that's the job. she renders. she dumps trees. she goes home. π
and a lil shoutout: thanks to Stevan Little, author of Tree::Simple::View, for giving the idea and for providing some code that could be snatched. π«Ά (stealing with permission is just collaborating, iykyk)
π EXAMPLE π
go check dhtml_test.pl for a complete example of two structure dumps within the same HTML file. two trees, one page, no drama. π
β OPTIONS β
π Style π
the CSS style gets dumped to $setup->{RENDERER}{STYLE} (a ref to a scalar) if it exists. the whole point is so you can hoard all the CSS in one place and then yeet it at the top of the HTML code. collect them all, bestie π«Ά
my $style ;
my $body = DumpTree
(
...
RENDERER =>
{
NAME => 'DHTML',
STYLE => \$style,
},
) ;
then {RENDERER}{NO_STYLE} removes style section generation entirely. super useful when you already defined your styles by hand and you're like "i got this, thank you." π
my $style ;
my $body = DumpTree
(
...
RENDERER =>
{
NAME => 'DHTML',
NO_STYLE => 1,
},
) ;
πΈ Class πΈ
the output will use the class data_tree_dumper_dhtml for <li> and <ul>. but bestie, you can rename that class with {RENDERER}{CLASS}. why would you? because it lets you dump multiple data structures and show them off with different styles. two trees, two lewks. slay π
my $style ;
my $body = DumpTree
(
...
RENDERER =>
{
NAME => 'DHTML',
CLASS => 'my_class_name',
},
) ;
π¦ Glyphs π¦
Data::TreeDumper outputs the tree lines as ASCII text by default. but listen: if {RENDERER}{NO_GLYPH} and {RENDERER}{NO_STYLE} are defined, no lines are output and the indentation will just be the default <li> style. β¨
and if you wanna specify a specific style for your tree dump? define your own CSS and set the appropriate class through {RENDERER}{CLASS}. you're the stylist now. π
π Expand/Collapse π
setting {RENDERER}{COLLAPSED} to a true value will display the tree collapsed. this is false by default, so don't come for me when it's expanded, that's just the factory setting π
$setup->{RENDERER}{COLLAPSED}++ ;
and if {RENDERER}{BUTTON}{COLLAPSE_EXPAND} is set, the renderer will add a button so the user can collapse and expand the tree themselves. interactive. main character. periodt π
$setup->{RENDERER}{BUTTON}{COLLAPSE_EXPAND}
π Search π
if {RENDERER}{BUTTON}{SEARCH} is set, the renderer will add a button that lets the user search the tree.
real talk though: this is a primitive search and it has no other value than for test. she's cute, she's not a search engine, don't ask her for more π
π Bugs π
quote of the century incoming: "I'll hapilly hand this module over to someone who knows what he does :-)" ππ the self-awareness is unmatched, honestly. respect. π«Ά
and: check the TODO file. there's always a TODO file. there will always be a TODO file. π
π EXPORT π
None. she exports nothing. she owes you nothing. she's simply too iconic for that. β¨
π§ AUTHORS π§
Khemir Nadim ibn Hamouda. <nadim@khemir.net>
Staffan MaahlΓ©n.
Copyright (c) 2003 Nadim Ibn Hamouda el Khemir and
Staffan MaahlΓ©n. All rights reserved.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perlitself.
and then, the sweetest part: "If you find any value in this module, mail me! All hints, tips, flames and wishes are welcome at <nadim@khemir.net>." β hints, tips, flames, wishes, all of it, send it in, they want it fr fr π«Άπ
π SEE ALSO π
Data::TreeDumper. that's the one. the origin. the blueprint. go read it bestie π
π POD ERRORS π
hey! the above document had some coding errors, which are explained below:
Around line 669:
Non-ASCII character seen before=encodingin'MaahlΓ©n.'. AssumingCP1252
not the encoding jumpscare π it's fine, it's fine, the accent was just too much for POD to handle. iconic behavior honestly.
aaaand that's the whole page! this was perl v5.36.0, dated 2022-11-20, and you've been reading DHTML(3pm) from the User Contributed Perl Documentation collection. mwah, go dump some trees, bestie π
πβ¨
π¦ where this page comes from
- debian bookworm: libdata-treedumper-renderer-dhtml-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-treedumper-renderer-dhtml-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-treedumper-renderer-dhtml-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-treedumper-renderer-dhtml-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-treedumper-renderer-dhtml-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms