vimzurb-foundationemmet

How do I get emmet to add an attribute with a value into a div tag?


I am using the emmet.vim plugin.

How do you write emmet shorthand to account for attributes with no values?

This is what I write:

div.contain-to-grid.sticky>nav.topbar[data-topbar]

This is what I want to happen:

<div class="contain-to-grid sticky">
  <nav class="topbar" data-topbar></nav>
</div>

This is what I get:

<div class="contain-to-grid sticky">
  <nav class="topbar" data-topbar=""></nav>
</div>

Instead of creating an attribute without a value:

data-topbar

it is creating an empty value:

data-topbar=""

Is there a work around for this? If not then I can live with it. It would be nice to know if it can be done. Thanks


Solution

  • The behaviour of Emmet-vim was changed to be as expected from documentation:

    You don’t have to specify attribute values: td[colspan title] will produce <td colspan="" title=""> with tabstops inside each empty attribute (if your editor supports them).

    So no. You can follow this request here: Attributes without values not being expanded.

    Possible crude workaround could be to change the line 220 in autoload/emmet/lang/html.vim from

    let current.attr[atts] = ''
    

    to

    let current.attr[atts] = function('emmet#types#true')