Example #1
0
def nav_links_new():
    nav_groups = (
        ('Basics', (
            ('/docs/basics/installation', 'Installation'),
            ('/docs/basics/syntax', 'Syntax'),
            ('/docs/basics/templating', 'Templating'),
            ('/docs/basics/utilities', 'Utilities'),
        )),
        ('Common Patterns', (
            ('/docs/patterns/abstraction', 'Abstractions'),
            ('/docs/patterns/composition', 'Composition'),
            ('/docs/patterns/reusability', 'Reusability'),
        )),
        ('Integrations', (('/docs/integrations/flask', 'Flask'), )),
    )

    tmpl = Template()
    nav = tmpl.ul(_class='list-unstyled')
    nav.li.a(href=url('/')) + 'Funky Bomb'

    for name, links in nav_groups:
        nav.li.p(_class='mt-3 mb-1') + name
        for u, text in links:
            nav.li.a(href=url(u)) + text

    nav.li.p(_class='mt-3 mb-1') + 'Other'
    nav.li.a(href='https://github.com/glennyonemitsu/funkybomb') + 'GitHub'

    return tmpl
Example #2
0
def nav_links(current_url, links):
    tmpl = Template()
    nav = tmpl.ul(_class='list-unstyled')
    for href, text, children in links:
        nav_item = nav.li()
        _class = ''
        if url == current_url:
            _class += 'active'
        nav_item.a(_class=_class, href=url(href)) + text
        if children:
            nav_item = nav.li()
            nav_item + nav_links(current_url, children)
    return nav