Quantcast

Include thymeleaf fragment in a javascript variable

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Include thymeleaf fragment in a javascript variable

test65002
Dear All,

I've tried during hours to include a thymeleaf fragment into a javascript variable without success. I would like to do something like this :

var myJavascriptVariable = /* A Thymeleaf fragment */;

I've tried lot of things, including this :

var myJavascriptVariable = [[~{myfile :: myfragment}]];

But it is not working... Could anybody help me?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Include thymeleaf fragment in a javascript variable

johnnybigoode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Include thymeleaf fragment in a javascript variable

test65002
I have already tried all those, it generates JavaScript's errors.

/*
<![CDATA[*/

    var myJavascriptVariable= /*[[~{myfile  :: myfragment}]]*/ null;
    console.log(myJavascriptVariable);

/*]]>
*/

This code gave me this error : "Uncaught SyntaxError: Unexpected token :"

Thanks for helping me.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Include thymeleaf fragment in a javascript variable

test65002
Somebody has an idea of how it can be done?
Loading...