Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: RFC: Templating without a System

by shmem (Chancellor)
on Jun 23, 2006 at 15:13 UTC ( [id://557220]=note: print w/replies, xml ) Need Help??


in reply to Re^3: RFC: Templating without a System
in thread RFC: Templating without a System

As you may have seen from my benchmarking code I was not re-parsing the HTML, every time round, but only calling process with a pre-parsed tree.

You're in a fix here.

Parsing HTML to a DOM tree gives you the freedom to manipulate every branch and twig and content as you like, but at the cost of speed. If you cache the modified tree or parts of it, you give away that freedom, as if you hadn't had it in the first place.

If if you have fixed places where elements are altered - as with your example pages produced from spkg.pl, there is no difference to static pages with inline perl as with Mason or with my approach.

In the sub process of spkg.pl-generated pages the names are even static:

sub process { my ($tree, $c, $stash) = @_; use Data::Dumper; warn "PROCESS_TREE: ", $tree->as_HTML; # $tree->look_down(id => $_)->replace_content($stash->{$_}) # for qw(name date); $tree; }

To have freedom of which node has to be altered with which value, the key/value pairs should be taken from $stash. But then, again, caching is ineffective.

That's why I think HTML::Seamstress is ok for template generation but not actually for serving pages.

regards,
--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-28 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found