refactoring jinja2 nav macro