Can I change the default variable separator in Freemarker?

I am working on a project where I generate code / scripts (specifically Perl scripts) through Java and Freemarker. I am working at the moment, but wondered if there is a way to change the default variable separator ($) in Freemarker?

Or is there another Java template engine that will use a variable separator more suitable for creating a Perl script?

+3
source share
3 answers

It can be assumed that such a function will be in the same place as the ability to choose between the angle bracket syntax and the square bracket syntax.

http://freemarker.org/docs/api/freemarker/template/Configuration.html

.

, : , .

+1

$foo, ${foo}.

perl, - $, :

$${foo} -> $FOO

<#noparse>${</#noparse>${foo}} -> ${FOO}

: -)

, - , perl , escape/noescape.

0

FTL.jj ${ } (a FM_EXPRESSION), , .

%{x} FTL ${x} , Perl :

% perl -spi.bak -e "s/\\$/\<#noparse\>\\$\<\/#noparse\>/g,s/\%\{/\\$\{/g" file

:

%{var}=${value}

:

${var}=<#noparse>$</#noparse>{value}
0

Source: https://habr.com/ru/post/1743997/


All Articles