def create_tag(<EOL>tag,<EOL>escaper=EscapedHTMLString,<EOL>opening_only=False,<EOL>body=None,<EOL>escape_body=False,<EOL>escape_attr=True,<EOL>indent=<NUM_LIT:0>,<EOL>attrs=None,<EOL>**other_attrs):
if attrs is None:<EOL><INDENT>attrs = {}<EOL><DEDENT>for key, value in iteritems(other_attrs):<EOL><INDENT>if value is not None:<EOL><INDENT>if key.endswith('<STR_LIT:_>'):<EOL><INDENT>attrs[key[:-<NUM_LIT:1>]] = value<EOL><DEDENT>else:<EOL><INDENT>attrs[key] = value<EOL><DEDENT><DEDENT><DEDENT>out = "<STR_LIT>" % tag<EOL>for key, value in iteritems(attrs):<EOL><INDENT>if escape_attr:<EOL><INDENT>value = escaper(value, escape_quotes=True)<EOL><DEDENT>out += '<STR_LIT>' % (key, value)<EOL><DEDENT>if body is not None:<EOL><INDENT>if callable(body) and body.__name__ == '<STR_LIT>':<EOL><INDENT>body = body()<EOL><DEDENT>out += "<STR_LIT:>>"<EOL>if escape_body and not isinstance(body, EscapedString):<EOL><INDENT>body = escaper(body)<EOL><DEDENT>out += body<EOL>if not opening_only:<EOL><INDENT>out += "<STR_LIT>" % tag<EOL><DEDENT><DEDENT>elif not opening_only:<EOL><INDENT>out += "<STR_LIT>"<EOL><DEDENT>if indent:<EOL><INDENT>out = indent_text(out, indent)[:-<NUM_LIT:1>]<EOL><DEDENT>from invenio_utils.text import wash_for_utf8<EOL>return EscapedString(wash_for_utf8(out))<EOL>
Create an XML/HTML tag.

This function create a full XML/HTML tag, putting toghether an
optional inner body and a dictionary of attributes.

    >>> print create_html_tag ("select", create_html_tag("h1",
    ... "hello", other_attrs={'class': "foo"}))
    <select>
      <h1 class="foo">
        hello
      </h1>
    </select>

@param tag: the tag (e.g. "select", "body", "h1"...).
@type tag: string
@param body: some text/HTML to put in the body of the tag (this
    body will be indented WRT the tag).
@type body: string
@param escape_body: wether the body (if any) must be escaped.
@type escape_body: boolean
@param escape_attr: wether the attribute values (if any) must be
    escaped.
@type escape_attr: boolean
@param indent: number of level of indentation for the tag.
@type indent: integer
@param attrs: map of attributes to add to the tag.
@type attrs: dict
@return: the HTML tag.
@rtype: string