17

Can you recommend a template engine for GAE? I like Wicket, but it carries a lot of server-side state, which is something that is not very compatible with the GAE approach.

Is FreeMarker supported on GAE?

EDIT

My primary requirements for the template engine are:

  • Ease of development (separation of logic and design)
  • Intuitive syntax, since users may customize some templates
  • Fast, lightweight
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
  • 1
    http://freemarker.blogspot.com/2010/02/freemarker-on-google-app-engine.html seems to indicate that FreeMarker is not (currently) supported in Java App Engine – Jason Hall Nov 09 '10 at 19:25
  • 2
    See http://code.google.com/p/googleappengine/wiki/WillItPlayInJava for a list of frameworks which will run in Java App Engine. – Jason Hall Nov 09 '10 at 19:26
  • 2
    What exactly are your requirements? JSP is available out of the box for GAE/J. – Robert Munteanu Nov 09 '10 at 20:43
  • freemarker is available for GAE now http://freemarker.blogspot.com/2010/02/freemarker-on-google-app-engine.html http://repo1.maven.org/maven2/org/freemarker/freemarker-gae/ – Somatik Jul 26 '11 at 13:12
  • "closed as not constructive"? Give me a break! +1 – Katedral Pillon May 31 '16 at 07:23

3 Answers3

7

Check out the Play framework. It has support for GAE and is completely stateless server-side.

Amy B
  • 17,874
  • 12
  • 64
  • 83
2

I am using FreeMarker on GAE quite successfully. I have it handling all of the html files with welcome-file directory handling working fine. For more information, see this other stackoverflow question. I have my web.xml file and other details there.

Community
  • 1
  • 1
Gray
  • 115,027
  • 24
  • 293
  • 354
  • I keep having an issue with my freemarker and eclipse , It doesn't seem to deploy the .ftl file to gae when i run mvn appengine:deploy , Please how did you get passed this ?. – I.Tyger Jun 21 '15 at 07:04
  • Sorry I've not used GAE for a while. I think I made the freemarker handler render all HTML files by default @I.Tyger. – Gray Jun 22 '15 at 18:27
1

Rythm is a Strong typed Java template engine using Razor like syntax with high performance (2 to 3 times faster than Velocity and FM). It provides a very lightweight way to do String interpolation:

String result = Rythm.render("hello @who!", "world");

This simplicity makes Rythm a good replacement for String.format() in many cases. Please be noted that Rythm.render is 2x faster than String.format

For comprehensive template you can use the same interface to pass in the file name:

Map<String, Object> args = new HashMap<String, Object>();
args.put("who", "world");
...
String result = Rythm.render("myTemplate.html", args);

Rythm has very rich feature set including java flow control (if-else, for loop, collection iteration), template inheritance, external and internal tags creation and invocation, caching, Java method extension, space compact, html escape etc. Most of the features are demonstrated at http://play-rythm-demo.appspot.com/. (And Yes, the demo is written with Play!Framework plus Rythm template engine and it is running on GAE!)

There is Play!Framework plugin created on Rythm engine, you can find documentation on how to use Rythm from there: http://www.playframework.org/modules/rythm

You can download Rythm from https://github.com/greenlaw110/rythm/downloads

Gelin Luo
  • 14,035
  • 27
  • 86
  • 139