0
a(data-track-dynamic-attrs='["Page","Stakeholder"]') Download App

This is the line in jade. Here for data-track-dynamic-attrs I have to add json data. I expect <a data-track-dynamic-attrs='["Page","Stakeholder"]' > </a> to be the generated html so as to parse json. But jade renders in double quotes instead of single quotes. In html it is rendered as <a data-track-dynamic-attrs="["Page","Stakeholder"]"></a>. Hence if I try to read given data attribute it will give me "[" instead of whole string.

Pyjade version I am using is 4.0.0

Himanshu Pandey
  • 726
  • 5
  • 13

1 Answers1

1

You could use double quotes on the outside and escaped double quotes on the inside.

a(data-track-dynamic-attrs="[\"Page\",\"Stakeholder\"]") Download App
Mike Cluck
  • 31,869
  • 13
  • 80
  • 91
  • It works. I tried that earlier before posting here and was trying to parse assuming it was string. But it was automatically parsed into array when value is fetched. Hence it was throwing error. Thanks any way. – Himanshu Pandey May 02 '16 at 16:33