[template] Don't patch references to the window object