def METHOD_NAME(tag):
    output = '<li class="tag">'
    # Hidden input for form state:
    if not self.async_urls:
        output += "<input%s />" % flatatt(
            {"value": force_str(tag.name), "type": "hidden", "name": control_name}
        )
        # Linkless tag name:
        output += '<span class="tag-name">%s</span>' % escape(tag.name)
    else:
        # Anchor for link to by-tag view:
        output += '<a class="tag-name" href="%s">%s</a>' % (
            escape(self.make_link(tag.slug)),
            escape(tag.name),
        )
    # Remove button:
    if not self.read_only:
        output += (
            '<input type="submit" '
            'value="&#x2716;" '
            'class="remover" '
            'name="remove-tag-%s" />' % escape(tag.name)
        )
    output += "</li>"
    return output