Javascript dom templating