Fix escaping of data-* attributes [closes #1075]

When objects are used as values for `data-` attributes,
the stringified JSON is delimited by single quotes,
so these must be replaced with HTML character entity references.
Merge pull request #1138 from qualiabyte/escape-data-attrs

Fix escaping of data-* attributes [closes #1075]