client side template generation code