Attach/detach contexts from stencils