How to inline javascript with thymeleaf
up vote
0
down vote
favorite
I could like to use thymeleaf to do inline javascript which jacascript is
<script th:inline="javascript">
/*<![CDATA[*/
/*[[${myCode}]]*/;
/*]]>*/
</script>
and the spring boot coding is
model.addAttribute("myCode", "alert("test")");
My output html is
<script th:inline="javascript">
/*<![CDATA[*/
"alert("test")";
/*]]>*/
</script>
which is a string. Can someone help me on that? Great thanks.
spring spring-boot thymeleaf
add a comment |
up vote
0
down vote
favorite
I could like to use thymeleaf to do inline javascript which jacascript is
<script th:inline="javascript">
/*<![CDATA[*/
/*[[${myCode}]]*/;
/*]]>*/
</script>
and the spring boot coding is
model.addAttribute("myCode", "alert("test")");
My output html is
<script th:inline="javascript">
/*<![CDATA[*/
"alert("test")";
/*]]>*/
</script>
which is a string. Can someone help me on that? Great thanks.
spring spring-boot thymeleaf
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I could like to use thymeleaf to do inline javascript which jacascript is
<script th:inline="javascript">
/*<![CDATA[*/
/*[[${myCode}]]*/;
/*]]>*/
</script>
and the spring boot coding is
model.addAttribute("myCode", "alert("test")");
My output html is
<script th:inline="javascript">
/*<![CDATA[*/
"alert("test")";
/*]]>*/
</script>
which is a string. Can someone help me on that? Great thanks.
spring spring-boot thymeleaf
I could like to use thymeleaf to do inline javascript which jacascript is
<script th:inline="javascript">
/*<![CDATA[*/
/*[[${myCode}]]*/;
/*]]>*/
</script>
and the spring boot coding is
model.addAttribute("myCode", "alert("test")");
My output html is
<script th:inline="javascript">
/*<![CDATA[*/
"alert("test")";
/*]]>*/
</script>
which is a string. Can someone help me on that? Great thanks.
spring spring-boot thymeleaf
spring spring-boot thymeleaf
asked Nov 7 at 12:19
JOE
133
133
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
When inlining, [[...]]
corresponds to th:text
and [(...)]
corresponds to th:utext
.
So
<script th:inline="javascript">
/*<![CDATA[*/
[(${myCode})]
/*]]>*/
</script>
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
add a comment |
up vote
0
down vote
Finally I got it.
<script th:inline="javascript">
/*<![CDATA[*/
[#th:block th:utext="${myCode}" /]
/*]]>*/
</script>
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
When inlining, [[...]]
corresponds to th:text
and [(...)]
corresponds to th:utext
.
So
<script th:inline="javascript">
/*<![CDATA[*/
[(${myCode})]
/*]]>*/
</script>
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
add a comment |
up vote
0
down vote
accepted
When inlining, [[...]]
corresponds to th:text
and [(...)]
corresponds to th:utext
.
So
<script th:inline="javascript">
/*<![CDATA[*/
[(${myCode})]
/*]]>*/
</script>
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
When inlining, [[...]]
corresponds to th:text
and [(...)]
corresponds to th:utext
.
So
<script th:inline="javascript">
/*<![CDATA[*/
[(${myCode})]
/*]]>*/
</script>
When inlining, [[...]]
corresponds to th:text
and [(...)]
corresponds to th:utext
.
So
<script th:inline="javascript">
/*<![CDATA[*/
[(${myCode})]
/*]]>*/
</script>
answered Nov 7 at 16:24
Metroids
6,52621124
6,52621124
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
add a comment |
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
It's work. and much simple. Thanks
– JOE
Nov 9 at 5:49
add a comment |
up vote
0
down vote
Finally I got it.
<script th:inline="javascript">
/*<![CDATA[*/
[#th:block th:utext="${myCode}" /]
/*]]>*/
</script>
add a comment |
up vote
0
down vote
Finally I got it.
<script th:inline="javascript">
/*<![CDATA[*/
[#th:block th:utext="${myCode}" /]
/*]]>*/
</script>
add a comment |
up vote
0
down vote
up vote
0
down vote
Finally I got it.
<script th:inline="javascript">
/*<![CDATA[*/
[#th:block th:utext="${myCode}" /]
/*]]>*/
</script>
Finally I got it.
<script th:inline="javascript">
/*<![CDATA[*/
[#th:block th:utext="${myCode}" /]
/*]]>*/
</script>
answered Nov 7 at 12:43
JOE
133
133
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189356%2fhow-to-inline-javascript-with-thymeleaf%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown