DOM template engine for client and server