I'm always looking for a modern Java library that makes creating valid (X)HTML snippets easy.
Yes you could use a templating language but there are times when you do not want to do this because Java has some advantages over insert your favorite templating language.
I have seen lots of in-house HTML builders in many projects but there is no Commons-HTML Builder that I can find.
Does anyone know of one?
It would be ideal if it took advantage of the Java 5/6/7 type system (generics) and support Fluent Style. Or something like fluent style ie JQuery style chaining, or a state machine used in mocking libraries like JMock (pedantically speaking a Monad).
A rough builder example might be:
new Html().title("stuff").body().in().div().in().h1("Hello World").hr();
Another example: http://codemonkeyism.com/the-best-markup-builder-i-could-build-in-java/
I ended up writing my own: Java Anti-template Language (JATL)