Skip to content

No clean way to conditionally add HTML tag attributes #2

@aspotashev

Description

@aspotashev

I want to add an attribute class="active" to an element when some condition (in C++) is true. I currently do it like this:
%a(href="/myurl" method="POST" class=(active ? "active" : ""))

Unfortunately, in this way the "class" attribute is always present, even when it's empty. This makes the resulting HTML code not very clean.

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