Reputation: 308763
I have a large number of Velocity templates that I'd like to convert to FreeMarker.
I found a converter tool called USCavalry that claimed to do the job.
I set it up in IntelliJ as a Maven project and added Velocity and Freemarker dependencies to my pom.xml.
The tool runs fine, but I'm not happy with the output I get. It appears to be the tokenized output of the AST. Proper FreeMarker symbols are not substituted.
Has anyone else run into this issue? What did you change to get a meaningful FreeMarker template as output?
I'm going to try modifying the source to output something other than the fruits of Velocity RuntimeServices.parse()
, but I thought it might help if someone else has already solved this problem.
Upvotes: 1
Views: 3611
Reputation: 31132
USCavarlry is a quite simplistic tool and is very outdated too (the web page linked is a 10 year old snapshot, and perhaps it was outdated even then). For very basic things it seems to work (like #if($x == 1)$y#end
is translated to <#if x == 1>${y}</#if>
, for me at least). Proper automatic translation is not possible even in theory, and doing it even half decently would be quite tricky (like you had to account for semantical differences like what counts as logical true in an if
condition, had to recognize the invocation of widely used Velocity tools and translate them to ?xxx
expressions, etc.). No such tool exists as far as I know. So it's mostly a manual task, with hand crafted regular expression substitutions and all... or you have to modify the USCavalry source code, whichever is the faster.
Upvotes: 3