Skip to content

Feature Request: new function html_attr to output html attributes the easy way #3193

@axten

Description

@axten

Hi, I would suggest to add a new helper function to manage html attributes in a simple way.

twig example:

    {% set attr = {
        'aria-expandend': 'false',
        disabled: true,
        hidden: false,
        id: 123,
        title: 'cli"<ck',
    } %}

    <button{{ html_attr(attr) }}>Test</button>

output:

<button aria-expandend="false" disabled id="123" title="cli&quot;&lt;ck">Test</button>

PR: #3199

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