12

I am new to using Jade -- and it's awesome so far.

But one thing that I need to happen is an element with 'itemscope' property:

<header itemscope itemtype="http://schema.org/WPHeader">

My Jade notation is:

header(itemscope, itemtype='http://schema.org/WPHeader')

But result is:

<header itemscope="itemscope" itemtype="http://schema.org/WPHeader">

How can I make sure that I get the right result -- itemscope instead of itemscope="itemscope"?

mvbl fst
  • 5,045
  • 5
  • 39
  • 58
  • 1
    itemscope="itemscope" will work just as well as just itemscope. It looks like that's the default behavior of Jade. I'd just go with it. – jwerre Jun 14 '12 at 17:34

5 Answers5

12

Sometimes it doesn't work quite right -- like with contentEditable Jade tries to detect html5 doctypes and then does <header itemscope itemtype="http://schema.org/WPHeader"></header> if it finds it. The problem is that if you have templates that you are inserting in the page, it can't tell that it's html5.

What you can do is force html5 compilation by passing in {doctype: '5'} to the options -- did this for require-jade: https://github.com/ibash/require-jade/commit/754cba2dce7574b400f75a05172ec97465a8a5eb

ibash
  • 1,363
  • 15
  • 30
10

I had the same problem using angular ng-include directive. It gets ng-include="ng-include" and then the include doesn'nt work.

What it works for me is to use an empty string as a value, i.e. ng-include="".

flacoloco
  • 111
  • 1
  • 3
  • 1
    Yeah I've been spending some time trying to get jade play along but it was definitely not written with angular in mind – ditoslav Jan 13 '16 at 16:45
8

Here is answer from jade developers: you should use

  doctype html

in the template.

https://github.com/pugjs/jade/issues/370

alehro
  • 2,131
  • 2
  • 24
  • 38
  • 1
    this comment should go on top of every `jade-template`. After which we don't need to assign `blank-string` values to the attributes. `doctype html` and next line `div#core(ui-view controller="CoreCtrl")`. Note the `ui-view` in the code. Thanks @alehro – Aakash May 17 '16 at 05:37
  • Yep, this was it. – taylorpalmer Dec 31 '16 at 04:06
6

I just tried it in a Express.js/Jade project and the result i get is:

<header itemscope itemtype="http://schema.org/WPHeader"></header>

I also tried it in bash and then I get the same result as you.

I'd go with the following suggestion or create an issue on Github.

itemscope="itemscope" will work just as well as just itemscope. It looks like that's the default behavior of Jade. I'd just go with it.

Pickels
  • 30,764
  • 23
  • 107
  • 174
  • Thanks. Strange that result is different. Alright, will go with this. – mvbl fst Jun 15 '12 at 00:04
  • This is still showing up in google searches. The correct solution for me was to set the attribute equal to the empty string. – Tim Jul 09 '16 at 03:50
1

I had the same problem, and the easiest solution in my case was adding doctype 5 at the top of my jade document. That apparently allows Jade to use attributes without a value. ibash put me on the right track with his answer, so thanks for that

Bob Vork
  • 2,879
  • 23
  • 31
  • 2
    The compiler says that: doctype 5 is deprecated, use html instead. Thus, I just write doctype html just before html(lang=en). FYI. – ankakusu Jun 05 '14 at 17:05