Create JavaScript Object from a template