You might write
First Name:
and the system would insert the firstName into that span, for instance.I've done the same thing in Java with tools like jsoup and HTMLUnit.
This system can rewrite links and do other interesting transformations on the guest HTML.
One thing I'll concede is that this is slow compared to the alternatives. In a crude test a system like this and not optimized might be able to transform 10-50 pages per second on a core whereas it is easy to get 3000+ with string based templates.
I haven't seen other people do this, are there any examples you of know of DOM-based templating? Any thoughts?