brutuscat brutuscat - 1 year ago 175
HTML Question

How to set an empty attribute using Jade?

When using jade, AngularJs and angular-translate I prefer to use the translate directive as an empty attribute.

But for some reason, when using empty attributes in Jade, instead of getting something like

<tag translate
<tag translate=''
, I'm getting
<tag translate='translate'

How can I add an attribute without a value?

Answer Source

The answer is to use the {doctype: "html"} when using the Pug (before was Jade) template engine.

This option has been documented recently, but it does not states what is it for.

Bear in mind that since I'm just processing all the jade files using gulp, I don't care that much about partials and such things...

Caveats: as stated by @lmacsen at github:

This fail if you need to use that code into a partial html file.

I've come up with this answer after reading several other github issues in the project page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download