DOM-based templating engine