brutuscat
brutuscat

Reputation: 3130

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 OR <tag translate='', I'm getting <tag translate='translate'

How can I add an attribute without a value?

Upvotes: 3

Views: 1178

Answers (2)

mamsoudi
mamsoudi

Reputation: 4059

I'm Using .foo(bar="") and it produces <div bar class="foo"></div>.

Using .foo(bar) you will get <div bar="bar" class="foo"></div>.

I'm Using most recent versions of Pug (formerly known as Jade) and I'm also using Partial jade files.

Upvotes: 1

brutuscat
brutuscat

Reputation: 3130

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.

https://github.com/pugjs/pug/issues/201#issuecomment-1530205 https://github.com/pugjs/pug/issues/1180

Upvotes: 3

Related Questions