Skip to content

add render_dropdown_item ? #387

@landryb

Description

@landryb

not finding a way to properly render dropdown menu items, I've had the need to complement render_nav_item by render_dropdown_item to add items to bootstrap dropdown menus.

the quickly hardcoded version is below, i can adapt it to provide the use_li conditional

{% macro render_dropdown_item(endpoint, text, _badge='', _badge_classes='badge text-bg-light') %}
    {% set active = True if request.endpoint and request.endpoint == endpoint else False %}
    <li>
    <a class="dropdown-item{% if active %} active" aria-current="page{% endif %}"
       href="{{ url_for(endpoint, **kwargs) }}">
        {{ text }} {% if _badge %}<span class="{{ _badge_classes }}">{{ _badge }}</span>{% endif %}
    </a>
    </li>
{% endmacro %}

would that be interesting as a PR ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions