Freemaker templates render variables with the following syntax: ${name}
Javascript ES6 template strings have a similar syntax ${name}
The problem is that when freemarker runs on the server, it will try to render the templates in the javascript code, because Freemarker thinks that it has encountered a variable (when in fact it is a javascript template that should be rendered on the client). Recommnedation on how to handle this?
One way is to wrap all the JS in a freemarker comment (so it is never evaluated),
or put the JS code in a seprate file (not inlined in the html page) so that it is never evaluated by freemarker.
you can use javascripts in noparse tags
<#noparse>...</#noparse>
or
const name = "WORLD";
Hello ${r"${name}"}
html view "Hello ${name}" output-> Hello WORLD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With