Re: Teething troubles
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.devel |
|---|---|
| Message-ID | <[email protected]> |
Thursday, March 8, 2012, 6:52:33 PM, Tim Pizey wrote:
> Hi,
>
> I am trying to enable some old software to use Freemarker in addition
> to Velocity.
> I am developing on Ubuntu/Eclipse.
>
> I am sorry to rush straight to the developer list, in my first 48
> hours of Freemarker use,
> but I could not find an IRC channel.
>
> I have used the binary cavalary.jar from
> http://freemarker.sourceforge.net/usCavalry.html
> to convert my velocity templates.
> This has left me with Velocity style variables eg
> ${table.TableInfo.Category.Name}
>>From the above page: "Also note that FreeMarker uses the Java built-in
> Beans introspection, so - contrary to Velocity - it completely adheres
> to introspection rules."
It's the mistake of usCavalry, I suppose. It should be
${table.tableInfo.category.name}
> It also converts colours into tags: <body bgcolor="<#call dddddd>" id="top">.
I guess that's because the *Velocity* parser thinks #dddddd is a macro
call. But when it doesn't find such a macro on runtime, it just prints
#dddddd. But the translator tool can't decide that no such macro will
be available on runtime (or can it?), so probably it should use some
heuristics to spot color codes.
> I am unable to contribute fixes as this code is not in the source tree.
I don't know where the source code is either... The tar.gz contains
two .java-s, yes. But I think the tricks happens inside
org.apacahe.velocity, that Jonathan has patched, and I don't see that
patch anywhere. It's my quick conclusion anyway.
There's also a tools/vel2ftl in the SVN repo. I have no idea what's
that, or if it works... But it surely doesn't look like usCavalry.
I will have to ask Jonathan...
> So my current hope is to modify BeansWrapper to understand Velocity
> style bean notation.
Don't do that... BeansWrapper uses standrad JavaBeans rules. Changing
that would be rather annoying for anyone who wants to work with the
templates later.
> I have checked out the source: in Eclipse I had to change the
> configuration to only warn on restricted access.
Um... what's that again?
> Building from source
> I documented my fix for ant/ivy on ubuntu at:
>
> http://stackoverflow.com/questions/1066976/building-freemarker-from-source
The current production version of FreeMarker, 2.3.x, with doesn't use
Ivy. Please use the SVN repo, not GIT. GIT contains 2.4, which is
unreleased.
> However the build still fails with unresolved dependency on
> http://repos.zeroturnaround.com/maven2/org/zeroturnaround/javarebel-sdk/1.2.2/javarebel-sdk-1.2.2.jar
> This may be because public access to http://repos.zeroturnaround.com/
> has been turned off.
>
> My main motivation is to be able to use beans such as
> ${table.TableInfo.Category.Name} to access a java object which I have
> placed in the root (context)
> with a name of table and for
> table.getTableInfo().getCategory().getName() to be discovered in that
> object.
>
> Which direction should I turn?
This has to be fixed in the converter. I'm not sure if I can contact
Jonathan (the author) and that he will do anything within a reasonable
time frame. So... maybe you should just do some regexp magic and
replace those capital letters after the dots. I don't know how many
templates do you have, however. But I'm certain nothing will translate
Velocity to FreeMarker perfectly... a tool may saves you from most
mechanical work, but you still will have to go through the templates
and change this and that, unless the Velocity templates were extremely
simple.
> cheers
> Tim
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/