add code behind for templates