question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preserve single quote attribute declarations

See original GitHub issue

Javascript libraries are challenging us these days with their complicated syntaxes.

The following is valid XML (see point [10] of http://www.w3.org/TR/xml/#sec-common-syn):

    <div data-options='{"number" : 3}'></div>

but Thymeleaf (as of 2.1.3.RELEASE) will transform it to the invalid

    <div data-options="{"number" : 3}"></div>

As a workaround, a user could use

    <div data-options="{&quot;number&quot; : 3}"></div>

or even

    <div data-options="{'number' : 3}"></div>

if their JSON parser allows this syntax (not JSON standard).

As Javascript libraries are becoming more and more popular, maybe Thymeleaf should preserve the type of quotes used originally in the template.

Question asked at http://forum.thymeleaf.org/Thymeleaf-process-on-single-quoted-attributes-td4028320.html

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielfernandezcommented, Sep 27, 2015

Already in 3.0.0-SNAPSHOT

0reactions
danielfernandezcommented, Sep 17, 2014

This situation will no longer happen in Thymeleaf 3.0, as the new underlying parser (attoparser) will preserve the original state of non-processable attributes: type of quotes, specification or not of a value, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserving single or double quotes around attributes in browser
I want to preserve single or double quotes around html attributes, specifically for innerHTML within the content editable div.
Read more >
Escape Single Quote in Attribute Value
Escape Single Quote in Attribute Value ... I have a flow that lists rows from a SQL table, then for each record determines...
Read more >
PreserveSingleQuotes - Adobe Support
Expression that evaluates to a string in which to preserve single-quotation marks. Usage. This function is useful in SQL statements to defer ...
Read more >
When to Use Double or Single Quotes in JavaScript - W3docs
Each type of quote should escape its own type. But there is no need to escape the other character inside a string. Hence,...
Read more >
How to use single and double quotes in PostgreSQL - Prisma
In general, if an item is a string, it needs to be surrounded by single quotation marks. Keep in mind that when creating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found