Passing JSON to <script> Tag #323
-
I'm using JTE with Kotlin to build server side rendered templates for a page with some SPA features. I resorted to pass complex JSON objects via In the default settings JTE escapes the json from the backend causing I could fix this by using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've found another way. JTE cannot know what I am trying to achieve 😄 |
Beta Was this translation helpful? Give feedback.
I've found another way. JTE cannot know what I am trying to achieve 😄
I created a small helper function which sanitizes the JSON string (escaping all
</script>
in the string) which returns gg.jte.Content with the sanitized string. This way I don't need to use$unsafe
and the output is properly sanitized.