implement .wrap for templates