English 中文(简体)
Which interoperable templating framework for JavaScript and Grails/Java?
原标题:

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 recommendations 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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签