Skip to content

No clean way to conditionally add HTML tag attributes #2

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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