Rewrite templates as objects