Is anyone aware of a template library for java similar in nature to Enlive?
The concept of using plain html for pages, without any markup inside, and to use the equivalent of CSS selectors to populate the page with dynamic data seems pretty good to me.
For more information what kind of templating I am looking for take a look at this blog post for an example.
I know that it would be possible to create Enlive wrapper in Java and use that, but I am looking at the existing Java alternative.
If it's not too late, I would suggest you have a look at Moulder, a templating library where generating a page is done by selecting elements from the original template and applying transformations on them. More resources on the subject:
Disclaimer: I am the author of this library.
because enlive depends on clojure's elegance of expression to do its magic an implamentation in java would likely loose that magic.
"The Enlive approach to templating is functional and decouples design and presentation logic." and " There is a kind of inversion of control here. In most mainstream templating systems, templates drive the presentation logic.". this would likely require extensive use of "the visitor pattern" to accomplish in a strait java library.
You'll likely be better off java-wrapping the parts you need to expose to the non-clojure world. and write your templates in clojure. Though I understand there are lots of good reasons why this approach may not fit within your project/organization.
I was looking the other night at the keynote of James Strachan at ScalaExchange about Scalate.
It is a templating engine which contains a set of template langauges. I've been looking at it to use the Mustache part, bu there is a templating system in it called Scuery which is also based on CSS/JQuery like selectors.
Actually it is a good presentation which shows implementation of a wide set of templating solutions. Scaml + Markdown looks really nice too.
Strictly speaking it is scala, but AFAICT you can just use the API from Java. Of course the some of template languages have scala based DSL's embedded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With