Javascript external files

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

Javascript external files

Gian Luca
HI,
I read that with thymeleaf 3 it will be possible access the model objects inside external Js and Css files using the JAVASCRIPT and CSS Template Mode.

first question:
can someone provide an example of how to do that? I mean the server side configuration plus the client side configuration.

second question:
i'm using the HTML template mode, can I still access the variables inside external javascript files ?
If yes what is the right way to do that. (linking the js file in the traditional way doesn't work).

I already experienced the th:include and th:replace with success, but I wanted to know if it is possible
avoid the inclusion and access the model values directly from js and css files.

thanks everybody
Gian Luca
Reply | Threaded
Open this post in threaded view
|

Re: Javascript external files

Zemi
Administrator
Hello,

there is a really simple example of the new template modes (with all configuration) on the migration guide
  http://www.thymeleaf.org/doc/articles/thymeleaf3migration.html

The example code is at
  https://github.com/jmiguelsamper/thymeleaf3-template-modes-example

About mixing template modes with includes, I don't think it is possible, but I am not completely sure indeed. The best option is trying it.

Regards,
   Zemi

Reply | Threaded
Open this post in threaded view
|

Re: Javascript external files

Gian Luca
Many thanks
Reply | Threaded
Open this post in threaded view
|

Re: Javascript external files

Gian Luca
I tried the method in the example that you provide me ad it works very well.
the only things (not related with thymeleaf) if that whe i produce (by mave plug in) my live minified javascript version, the closure compiler remove all my /* */ (comment) block :D

i'm figuring out a kind of workaround.

many thanks
Gian Luca