Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

HTML::TreeBuilder makes pure HTML templating possible, but rigid

by princepawn (Parson)
on Sep 20, 2001 at 21:26 UTC ( [id://113643]=perlmeditation: print w/replies, xml ) Need Help??

Take a look at this HTML document, which HTML::TreeBuilder's dump() method has annotated each node of the HTML document with a unique identitifer:
<html> @0 <head> @0.0 (IMPLICIT) <body> @0.1 (IMPLICIT) <table supply="_aref::load_data"> @0.1.0 <tr iterator="supply.Next"> @0.1.0.0 <th> @0.1.0.0.0 "name" <th> @0.1.0.0.1 "age" <th> @0.1.0.0.2 "weight" <td builder="_text::iterator.name"> @0.1.0.0.3 <td builder="_text::iterator.age"> @0.1.0.0.4 <td builder="_text::iterator.weight"> @0.1.0.0.5

It would be possible to tie each identifier to an anonymous subroutine:

my %dynamic_html = ( '@0.1.0.0.5' => sub { my $node = shift; $node->splice_content(0,1,'ne +w text'} }
for pure Perl and pure HTML templating (ie, absolutely no foreign elements in the HTML.

However, the problem would be that the mapping would have to change each time that the HTML changed the tree-numbering.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://113643]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-09-21 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (26 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.