Adding data attribute to slim with no value

Viewed 1238

I have the html <nav class="top-bar" data-topbar role="navigation"> from https://foundation.zurb.com/sites/docs/v/5.5.3/components/topbar.html. But I'm not sure how this converts to slim.

nav class="top-bar" role="navigation" data-topbar

This causes problems because data-topbar has no value.

nav class="top-bar" role="navigation" data-topbar=''

This is valid slim but it adds the ='' which I don't want. Is there any way to add this attribute with no value in slim?

1 Answers

If you write like this:

nav class="top-bar" role="navigation" data-topbar

You will get this:

<nav class="top-bar" role="navigation">data-topbar</nav>

If you write like this:

nav(class="top-bar" role="navigation" data-topbar)

When you inspect code you will see

<nav class="top-bar" data-topbar role="navigation"></nav>

But when you copy the dom or view source code you will get this one (like every boolean attributes)

<nav class="top-bar" data-topbar="" role="navigation"></nav>
Related