示例#1
0
文件: htmlutils.py 项目: notator/mnx
def get_element_subtree(current_url: str, el: XMLElement, els_seen: list):
    el_url = get_relative_url(current_url, el.get_absolute_url())
    result = [f'<a href="{el_url}">{htmlescape(el.name_with_brackets())}</a>']
    if el.id not in els_seen:
        els_seen.append(el.id)
        children = el.get_child_elements()
        if children:
            result.append('<ul class="nestedul">')
            for child in children:
                result.append('<li>')
                result.extend(get_element_subtree(current_url, child,
                                                  els_seen))
                result.append('</li>')
            result.append('</ul>')
        els_seen.pop(-1)
    else:
        result.append('(recursive)')
    return result
示例#2
0
文件: tags.py 项目: jsawruk/mnx
def relative_url(context, view_name, *args):
    url_string = reverse(view_name, args=args)
    return get_relative_url(context['request'].path, url_string or '')
示例#3
0
文件: tags.py 项目: jsawruk/mnx
def make_urls_relative_callback(path, match):
    return get_relative_url(path, match.group(0))
示例#4
0
文件: tags.py 项目: jsawruk/mnx
def relative_url_string(context, url_string):
    return get_relative_url(context['request'].path, url_string or '')