Returns all *args* (strings) wrapped in HTML tags like so::

            >>> b = TagWrap('b')
            >>> print(b('bold text'))
            <b>bold text</b>

        To add attributes to the tag you can pass them as keyword arguments::

            >>> a = TagWrap('a')
            >>> print(a('awesome software', href='http://liftoffsoftware.com/'))
            <a href="http://liftoffsoftware.com/">awesome software</a>

        .. note:: :meth:`~TagWrap.wrap` will automatically convert '<', '>', \
        and '&' into HTML entities unless the wrapped string has an `__html__` \
        method

def wrap(self, tag, *args, **kwargs):
        """
        Returns all *args* (strings) wrapped in HTML tags like so::

            >>> b = TagWrap('b')
            >>> print(b('bold text'))
            <b>bold text</b>

        To add attributes to the tag you can pass them as keyword arguments::

            >>> a = TagWrap('a')
            >>> print(a('awesome software', href='http://liftoffsoftware.com/'))
            <a href="http://liftoffsoftware.com/">awesome software</a>

        .. note:: :meth:`~TagWrap.wrap` will automatically convert '<', '>', \
        and '&' into HTML entities unless the wrapped string has an `__html__` \
        method
        """
        template = "<{tagstart}>{content}</{tag}>"
        if tag in self_closing_tags:
            template = "<{tagstart}>" # self-closing tags don't have content
            if self.ending_slash:
                template = "<{tagstart} />"
        content = ""
        for string in args:
            if not hasattr(string, '__html__'): # Indicates already escaped
                string = self.escape(string)
            content += string.__html__()
        tagstart = tag
        if kwargs:
            tagstart += ' '
            for key, value in kwargs.items():
                key = key.lstrip('_')
                if value == True:
                    tagstart = tagstart + key + ' '
                elif value == False:
                    continue # skip it altogether
                else:
                    tagstart = tagstart + '{key}="{value}" '.format(
                        key=key, value=value)
            tagstart = tagstart.rstrip()
        html = template.format(tagstart=tagstart, content=content, tag=tag)
        if self.safe_mode:
            html, rejected = strip_xss(
                html, whitelist=self.whitelist, replacement=self.replacement)
            if self.log_rejects:
                logging.error(
                    "{name} rejected unsafe HTML: '{rejected}'".format(
                    name=self.__class__.__name__, rejected=rejected))
        html = HTML(html)
        html.tagname = tag # So we can easily append()
        return html