Question

When I type the following text into an editor that understands emmet:

div.fragment>pre>code.javascript[contenteditable]

it expands to:

<div class="fragment">
    <pre><code class="javascript" contenteditable=""></code></pre>
</div>

Which is almost perfect, except that the boolean attribute shouldn't have the quotes. Is there a way to write the shortcut so that it expands properly like this:

<div class="fragment">
    <pre><code class="javascript" contenteditable></code></pre>
</div>
Was it helpful?

Solution

As of October 2013 this is now possible.

input[type=checkbox checked.]

Typing a single period (.) directly after the boolean attribute will produce the following output by default:

<input type="checkbox" checked="checked" />

If you want Emmet to output the attribute name without the argument e.g.

<input type="checkbox" checked />

You'll need to add the following key-value pair to the 'html' object in your Emmet user settings (Mac: 'Sublime Text' > 'Preferences' > 'Package Settings' > 'Emmet' > 'Settings - User')

"compact_bool": true

OTHER TIPS

No, Emmet currently doesn’t support boolean attributes. It will require extra effort and syntax upgrade to explicitly specify boolean attributes in abbreviation. You can create an issue for this: https://github.com/emmetio/emmet/issues

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top