Example #1
0
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
Example #2
0
File: tags.py Project: 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 '')
Example #3
0
File: tags.py Project: jsawruk/mnx
def make_urls_relative_callback(path, match):
    return get_relative_url(path, match.group(0))
Example #4
0
File: tags.py Project: jsawruk/mnx
def relative_url_string(context, url_string):
    return get_relative_url(context['request'].path, url_string or '')