Template engine recommendations

  • Thread starter Deleted member 43669
  • Start date
Status
Not open for further replies.
D

Deleted member 43669

Guest
I'm looking for a template engine. Requirements:

* Runs on a JVM. Java is good; Jython, JRuby and the like, too...
* Can be used outside of servlets (unlike JSP)
* Is flexible wrt. to where the templates are stored (JSP and a lot of people require the templates to be stored in the FS). It should provide a template loading interface which one can implement or something like that
* Easy inclusion of parameterized templates- I really like JSP's tag fragments
* Good docs, nice code, etc., the usual suspects

I've looked at JSP- it's nearly perfect except for the servlet and filesystem coupling, Stringtemplate- I love the template syntax, but it fails on the filesystem coupling, the documentation is lacking and template groups and stuff are confusing, GXP, TAL, etc.

Ideas, thoughts?

Alex
 

spankalee

Ars Tribunus Militum
2,063
You might take a look a GXP: http://code.google.com/p/gxp/wiki/WhyGxp

On the surface it fails your FS requirement, because you typically compile templates when you build your project. But in terms of a better JSP, it's very good. You could wire the compiler up to work off of a non-FS source, but that may be too much trouble.

It's an XML format, which you might not like, but it does a ton of compile-time checking of the templates and they get compiled into Java objects.

I like Django templates, and I'm sure there's a JVM version out there (or Jinja on Jython), but it's very different from JSP.
 

w_mute

Ars Scholae Palatinae
1,139
Subscriptor++
What about Velocity? I haven't used it much but it looks like it will work fine from non-file templates as it has pre-built resource (template) loaders for files, strings, and data sources (org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader).

It looks like in the configuration you point to a handle and define which Velocity side attributes (template name, etc) map to which DB table columns.

-Greg
 
Status
Not open for further replies.