Improved client side template data and JavaScript regex replace routine