One other thing is that Petal templates can be compiled down to a very fast form. Last year I had them running as fast as Text::Template (and with some syntax tweaks, considerably faster) but the changes were never integrated into Jean Michel's releases. Something which manipulates HTML trees at run time can't do this.Here, you have hit the nail dead on the head. You have found the Achilles' Heel of HTML::Seamstress. I had parried and dodged and ducked, but here is where you achieve touche'. Seamstress does runtime tree manipulations with the number of tree traversals per page linear to the number of templating actions. Put in plain talk: each time you need to do some sort of templating action you need to search through the tree to do it.
I recently began work on a compiler to optimize this but quit doing it after realizing that under mod_perl, the HTML tree needs to be created afresh for each new templating operation: I found this out in my test suite. When the first test case was fine but all the rest kept failing. Then I printed out the tree and OMG! The tree is mangled! Must start afresh!
Thanks for the reference to METAL, I had not heard of that. I learned some things about Petal from this. I have noticed a number of repetitive idioms in my HTML manipulation and may one day create shortcuts and a compiler for them. It's just right now I don't want to be telepathic about what I might need.