Java template engine recommendation

1,287 views
Skip to first unread message

Tim Fox

unread,
Apr 22, 2014, 4:55:43 PM4/22/14
to ve...@googlegroups.com
Can anyone recommend a good template engine?

This would be for creating other language APIs from our Java APIs. So
basically it needs to take a String (or stream) as input and output a
String (or stream). It needs to support iteration and recursion. It's
not for generating html/xml so I'm not interested in html/xml specific
template engines.

Also:

Must be written in Java
Low number (preferably zero) third party jar dependencies


Arno Schulz

unread,
Apr 22, 2014, 5:00:14 PM4/22/14
to ve...@googlegroups.com
Just came across http://www.walkmod.com/ not sure if it's what you are looking for
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Yates

unread,
Apr 22, 2014, 5:04:46 PM4/22/14
to ve...@googlegroups.com

String template looks fairly comprehensive

http://www.stringtemplate.org

BSD licence, but a dependency on antlr4 which might cause issues with other languages?

Arno Schulz

unread,
Apr 22, 2014, 5:24:26 PM4/22/14
to ve...@googlegroups.com
Sorry walkmod actually uses other template engines such as string template, groovy templates or apache velocity as modules.

Arno Schulz

unread,
Apr 22, 2014, 6:03:44 PM4/22/14
to ve...@googlegroups.com
+1 on stringtemplate it's used in  sikuli slides  http://slides.sikuli.org/ to add variables in powerpoint slides that get converted into a java class

Alexander Lehmann

unread,
Apr 22, 2014, 6:29:29 PM4/22/14
to ve...@googlegroups.com
I'm not sure I got what you want to use the templates for, but freemarker is a pretty good template tool which is aimed at generic output formats (including plain text and source code), which has no dependencies as far as I can tell.

Diego López León

unread,
Apr 22, 2014, 6:38:52 PM4/22/14
to ve...@googlegroups.com
Take a look at MVEL
http://mvel.codehaus.org/Templating%20Guide, it's used by the JBoss
Drools project.
> --
> You received this message because you are subscribed to the Google Groups
> "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vertx+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
diego

Diego López León

unread,
Apr 22, 2014, 6:44:41 PM4/22/14
to ve...@googlegroups.com
btw, mvel has 0 dependencies and a pretty responsive leader, Mike
Brock. You probably know him
--
diego

Amit Kumar

unread,
Apr 23, 2014, 11:37:50 PM4/23/14
to ve...@googlegroups.com
+1 FreeMarker

Amit Kumar

unread,
Apr 24, 2014, 9:51:26 AM4/24/14
to ve...@googlegroups.com
Recently, I was playing with linkedin dustjs for templating using javascript. Your requirement seems to be auto-API generation and I have seen people use Velocity as the template engine in the past. However, the perception is "it is too slow and heavy". Now, it depends whether the "api generation" is done at runtime or you are planning on vert.x utility that will generate the API before runtime.

In all, just to your criteria - FreeMarker fits the best I would say. 

On Wednesday, April 23, 2014 11:37:50 PM UTC-4, Amit Kumar wrote:
+1 FreeMarker

robert cooke

unread,
Apr 25, 2014, 8:03:41 AM4/25/14
to ve...@googlegroups.com
We are using google closure templates and really enjoy working with it.

Venkat

unread,
Apr 25, 2014, 9:20:33 AM4/25/14
to ve...@googlegroups.com
+1 for freemarker

Olaf Geibig

unread,
May 9, 2014, 3:59:53 AM5/9/14
to ve...@googlegroups.com
I'd really look into Groovy templates. I cannot say if it's good enough to generate APIs as I rather used it for HTML email generation. But I think for your purpose it might be beneficial that Groovy is already in the project and the API geneartion could be then easily done from a Gradle build script, even scripted directly in Gradle as you can just use Groovy in Gradle scripts.

JC

unread,
May 9, 2014, 6:36:07 AM5/9/14
to ve...@googlegroups.com
Today I'd pick MVEL.
Honorable mention: I used Velocity previously for Java code generation and it worked fine (and Apache CXF/JBoss Fuse use it too) so I presume Freemarker would work too.
S
Reply all
Reply to author
Forward
0 new messages