grep for text using templates