开发者

Which interoperable templating framework for JavaScript and Grails/Java?

开发者 https://www.devze.com 2023-02-09 09:33 出处:网络
I am currently researching templating frameworks that have implementations for both JavaScript and Grails/Java for an upcoming project that will render templates both within a Grails application and o

I am currently researching templating frameworks that have implementations for both JavaScript and Grails/Java for an upcoming project that will render templates both within a Grails application and on the front end.

The requirements are as follows:

  • implementations in both JavaScript and Grails / Java
  • front-end and back-end rendering produces the same output given the same JSON data
  • straightforward to author and maintain by a team of developers
  • testable on both front-end and back-end
  • can handle nested JSON objects without too much trouble
  • XSS protection on the front-end

So far, I have investigated Mustache which has JavaScript and Java implementations, and Haml which has JavaScript and Grails implementations. (I would link the implementations, but as a new user I am only able to add 2 links.)

I would be grateful for any experience others have had with these, and any recomm开发者_JAVA技巧endations for other frameworks that may fit the above needs.


Did you look at Closure Templates? There's also a Grails plug-in. It meets most if not all your requirements.


I've used both Mustache and Haml at one point or another. If you hadn't mentioned either, I would probably have recommended Mustache as a pure templating solution. Haml is great, but it is more a replacement for authoring html (i.e. you don't write html any more, you write haml). Mustache on the other hand is all about templating

I think either one would be a fine choice. Mustache.js is mature, the java implementation is probably less so, but it has been around for a little while, so you're probably ok in that regard. I am not sure how mature the javascript or grails Haml implementations are.

I'd be leaning towards Mustache if all you're after is templating, it is very good although it takes a little while to get used to the whole {{}} syntax. But if you're attracted to Haml as a replacement for writing HTML it might tip you in that direction.


ExtJS has a complete library of widget that you can build you app with. It works nicely with Grails as JSON data provider.

0

精彩评论

暂无评论...
验证码 换一张
取 消