Search code examples
freemarkerbackticks

Back-ticks in FTL


I was wondering if it is appropriate to use back-ticks (`) in (Freemarker template language) FTL template.

The FTL documentation https://freemarker.apache.org/docs/dgui_template_exp.html doesn't say anything about back-ticks.

But if used in script tag, it does work!

<script charset="utf-8" type="text/javascript">
var x = "Some string";
var y = `${x}`;
</script>

The above script works in FTL. Is it appropriate to use it and will it work in all cases ?


Solution

  • Back-tick is not a valid operator in FreeMarker. In your example it's part of the static text though, which is just printed as is by FreeMarker. So in static text you can have anything (except, these will end the static text: ${, #{, <#, </#, <@, </@).