Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jade : New warning on multiple attributes

I have updated jade to latest version, and started seeing this message in console

You should not have jade tags with multiple attributes

It is mentioned as feature, here

0.33.0 / 2013-07-12
Hugely more powerful error reporting (especially with compileDebug set explicitly to true)
Add a warning for tags with multiple attributes

and I see it in the code. https://github.com/visionmedia/jade/blob/a38aa552f6f53554ac5605299b6b8c7e07cbdf1f/lib/parser.js#L662

But, what does it really signify. When will I get this warning. For example, when will I get error based on the below code (It works without warning, but to like to know when will I get error so that I can compare with my code)

mixin link(href, name)
    a(class=attributes.class, href=href)= name
    a(href=href, attributes)= name

    +link('/foo', 'foo')(class="btn")
like image 905
bsr Avatar asked Oct 04 '13 15:10

bsr


1 Answers

Multiple "attributes" doesn't mean what you probably think it means. It's not an HTML attribute as we know it, but a token of type "attribute".

Example:

a(href="#WAT").some-class(title="WAT")

Note how I have two attribute sections, each with one attribute.

Better put them in one attribute section:

a(href="#WAT", title="WAT").some-class
like image 128
Prinzhorn Avatar answered Oct 21 '22 10:10

Prinzhorn