I covered a few people's attempts at this in my
Choosing a Template System essay. My favorite example of this type is the now defunct
HTML_Tree. It never really caught on. There have been other tries in Java, like
XMLC. They also failed to gather a large following. Most people stayed with things like JSP and Velocity.
I think the reality is that DOM-based HTML manipulation gets cumbersome for complex templates. It also ties your code very tightly to the presentation. Manipulation based on HTML ID attributes works better, since the code no longer has to know as much about where they are. Petal and Template::TAL are XML-friendly but don't seem to offer more separation than Template Toolkit and the like, i.e. the XML they use is just another template language.
So, if you want to pursue this, I'd suggest moving away from the DOM-like approach in your example and going to something more like HTML_Tree, HTML::Seamstress, and XMLC.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.