aeipownu
aeipownu

Reputation: 107

Duplicate attribute "{" is not allowed in Jade

I'm trying to put a script into jade, but it won't let me use multiple curly braces. Here is the chartist code I am trying to put in jade.

body
    h1 Crimes by Category
    .ct-chart
    script(new Chartist.Bar('.ct-chart', {
    labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
    series: [20, 60, 120, 200, 180, 20, 10]
    }, {
    distributeSeries: true
    });)

I am getting Duplicate attribute "{" is not allowed. I don't know how to get around this. Any help would be appreciated.

Upvotes: 2

Views: 832

Answers (1)

pcothenet
pcothenet

Reputation: 401

To insert multi-line javascript in Jade, use the script. tag (with the content of the script indented):

body
    h1 Crimes by Category
    .ct-chart

      script.
        new Chartist.Bar('.ct-chart', {
        labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
        series: [20, 60, 120, 200, 180, 20, 10]
        }, {
        distributeSeries: true
        });

You probably also need to indent script. one notch if you want it inside your .ct-chart div.

source: How can I render inline JavaScript with Jade / Pug?

Upvotes: 4

Related Questions