New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outputting a JS array outside th:inline script tag #980
Comments
This question is probably best asked on StackOverflow, as this is not a Thymeleaf bug. If you want single quotes and square brackets inside said String you will need to add them yourself. Something like
should probably work. Here is the documentation on how to escape a single quote in SpEL |
Maybe this should be a feature request instead? Tons of different technologies today use "templated javascript" driven by attributes, like i cant in any shape of form call this modern :P More like 2005..
🤮
🤩 |
If you have a Jackson Please also have a look at this Stackoverflow post and this one on how to get the ObjectMapper to output single instead of double quotes. |
We have used this as a workaround yes, but then we need to use |
Trying to output a string array into my DOM, but for our usage (js library) we need that in a HTML attribute like so
In this case, its just not possible to extract it to a
<script th:inline>
tag, nor is it convenient even if it worked.what we want to do is ofc this:
obviously that gives
so then ofc im looking for some TH helpers
which gives
No brackets, no quotes. How is this a string array?? (obviously
#arrays.toStringArray
doesn't help either, as it only converts to type)Is there a way to solve this?
The text was updated successfully, but these errors were encountered: