ram
ram

Reputation: 559

Dynamically set ID in UnderscoreJS template generated using Jade

I'm using Jade to generate JST templates but I'm having trouble setting placeholder for the id field.

.somediv(id=<%= id %>)
    ...

Jade compiler throws an error for the above syntax

undefined:501
buf.push(attrs({ terse: true, 'id':(<%= id %>), "class": ('somediv') 

Is there a way to do this?

Upvotes: 0

Views: 387

Answers (1)

Andrey Kuzmin
Andrey Kuzmin

Reputation: 4479

Correct syntax for attributes seems to be:

.somediv(id=id)
    ...

But if you need id to be exactly <%= id %> then you have to quote it and use != for values that shouldn't be escaped

.somediv(id!="<%= id %>")
    ...

Upvotes: 1

Related Questions