Skip to content

Add rootAttributes rendering option #166

Description

@dirkluijk

Hi,

I want to set the root attributes of a menu from inside a Twig template. I am working on a project where different themes need to have different CSS classes for the menu, and it seems quite ugly to override the MenuBuilder just to change the childAttributes of the root item.

My suggestion is to add a rootAttributes option to the default renderers.

Example usage (Twig renderer):

{# render Bootstrap nav #}
{{ knp_menu_render('main', {
    'currentClass': 'active',
    'rootAttributes': { class: 'nav navbar-nav' }
}) }}

If you agree, I could submit a PR with all necessary changes to the default renderers, docs and twig template.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions