Enhancing the performance of an electrochromic device by template synthesis of the active layers