Search code examples
javascriptjsonpugpyjade

Not able to add json data to data-attribute in pyjade


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


Solution

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

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