(val, key=None, level=0, timeago=False)
return ret
Recursively convert a value to its HTML representation using <dl>s for
    dictionaries and <ul>s for lists.
Recursively convert a value to its HTML representation using <dl>s for
    dictionaries and <ul>s for lists.
Recursively convert a value to its HTML representation using <dl > s for dictionaries and <ul > s for lists .
def _to_html(val, key=None, level=0, timeago=False):
    """
    Recursively convert a value to its HTML representation using <dl>s for
    dictionaries and <ul>s for lists.
    """
    recurse = lambda k, v: _to_html(v, key=k, level=level + 1, timeago=timeago)

    def _key_format(k, v):
        if not _is_list_like(v):
            return _format_slug_string_for_display(k)
        else:
            return ""

    if isinstance(val, dict):
        ret = format_html(
            "<dl {}>{}</dl>",
            mark_safe("class='well'") if level == 0 else '',  # nosec: no user input
            format_html_join(
                "",
                "<dt>{}</dt><dd>{}</dd>",
                [(_key_format(k, v), recurse(k, v)) for k, v in val.items()]
            )
        )

    elif _is_list_like(val):
        ret = format_html(
            "<dl>{}</dl>",
            format_html_join("", "<dt>{}</dt><dd>{}</dd>", [(key, recurse(None, v)) for v in val])
        )

    elif isinstance(val, datetime.date):
        if isinstance(val, datetime.datetime):
            fmt = USER_DATETIME_FORMAT
        else:
            fmt = USER_DATE_FORMAT

        iso = val.isoformat()
        ret = format_html("<time{timeago} title='{title}' datetime='{iso}'>{display}</time>".format(
            timeago=mark_safe(" class='timeago'") if timeago else "",  # nosec: no user input
            title=iso,
            iso=iso,
            display=safe_strftime(val, fmt)
        ))
    else:
        if val is None:
            val = '---'

        ret = escape(val)

    return ret
def _to_html ( val , key = None , level = 0 , timeago = False ) : recurse = lambda k , v : _to_html ( v , key = k , level = level + 1 , timeago = timeago ) def _key_format ( k , v ) : if not _is_list_like ( v ) : return _format_slug_string_for_display ( k ) else : return "" if isinstance ( val , dict ) : ret = format_html ( "<dl {}>{}</dl>" , mark_safe ( "class='well'" ) if level == 0 else '' , # nosec: no user input format_html_join ( "" , "<dt>{}</dt><dd>{}</dd>" , [ ( _key_format ( k , v ) , recurse ( k , v ) ) for k , v in val . items ( ) ] ) ) elif _is_list_like ( val ) : ret = format_html ( "<dl>{}</dl>" , format_html_join ( "" , "<dt>{}</dt><dd>{}</dd>" , [ ( key , recurse ( None , v ) ) for v in val ] ) ) elif isinstance ( val , datetime . date ) : if isinstance ( val , datetime . datetime ) : fmt = USER_DATETIME_FORMAT else : fmt = USER_DATE_FORMAT iso = val . isoformat ( ) ret = format_html ( "<time{timeago} title='{title}' datetime='{iso}'>{display}</time>" . format ( timeago = mark_safe ( " class='timeago'" ) if timeago else "" , # nosec: no user input title = iso , iso = iso , display = safe_strftime ( val , fmt ) ) ) else : if val is None : val = '---' ret = escape ( val ) return ret