Template calls in <script> blocks are not allowed
- jte: 3.1.16
- mvn:
<contentType>Html</contentType> - mvn build error
Template calls in <script> blocks are not allowed.
- This is to much opinionated, you must allow developers to decide
What's your use case?
From java I set some local storage, some javascript values,...
Why do you put the Javascript into a different template? How does your code look like?
because backend generate some staff for the user, I can't put code here on github
I'm facing the exact same issue. A template engine shouldn't check this. I can understand, that this could be a security concern in certain scenarios, but it makes jte entirely useless in other scenarios. Is there any way to skip this test?
If you share code examples, we can suggest alternatives that are safe and secure instead.
Putting a template into a script tag is not necessarily insecure.
Of course, but the likelihood is very high. If you don't share an example, we can't suggest alternatives.
Just an idea: To pass values to JavaScript using JTE, you could use HTML data attributes. Set the data attribute values with JTE and access them with JavaScript as described in this MDN article. Would this fit your use case?