Java Template library similar to ZPT (attribute language)
Asked Answered
D

7

2

I've been using ZPT in python recently and I love the templating language. I was looking for something similar for Java but couldn't really find anything I liked as well. The closest thing is FreeMarker.

The problem with FreeMarker and the other Java template engines I looked at was their JSP style syntax that allows for non-conforming XML. I was just wondering if there was a Java template engine that is similar to Zope Page Templates such that it's an "attribute" language that requires valid xml.

Dictatorship answered 3/11, 2011 at 20:25 Comment(0)
A
2

I think think there quite some of the template engines your looking for:

Other approaches supporting valid html are:

Analogue answered 5/11, 2011 at 0:3 Comment(0)
L
1

FreeMarker has a nasty dependency on AWT. It makes it impossible to use with things like Google App Engine.

I prefer to use StringTemplate for all my Java templating needs. It is the only Java based template system that strictly separates the logic from the template.

StringTemplate is a java template engine (with ports for C#, Python, Ruby, and Scala) for generating source code, web pages, emails, or any other formatted text output. StringTemplate is particularly good at multi-targeted code generators, multiple site skins, and internationalization/localization

Its distinguishing characteristic is that it strictly enforces model-view separation unlike other engines. Strict separation makes websites and code generators more flexible and maintainable; it also provides an excellent defense against malicious template authors.

Since you are generating XML

Another solution that isn't obvious at first sight is using JAXB. We have a project here that requires us to generate XML, we have very well defined XSD files for the output files, building the objects and marshalling them is super easy and very painless.

Legere answered 3/11, 2011 at 20:30 Comment(0)
D
1

The java template engine you will find to be most similar to Chameleon is Thymeleaf.

Dissyllable answered 22/2, 2012 at 13:34 Comment(0)
L
1

There is Distal for client based templating.

Limb answered 13/3, 2012 at 7:24 Comment(0)
G
1

There are currently two implementations for Java that I know of:

Goiter answered 11/7, 2012 at 15:5 Comment(0)
G
0

There is also Apache Velocity. Although it doesn't require that your templates be valid XML. That may be a deal breaker for you given the question. You could likely enforce that rule with extensions to the core classes though.

Goofball answered 3/11, 2011 at 21:15 Comment(0)
F
0

What about GXP?

There's also LSP and xtempore.

Folberth answered 5/11, 2011 at 0:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.