Client side template language using java compiler (dry template)

I want to be able to define templates once and use them to render HTML from the server and client (dry principle and all)

The API I envision is like this: render (JSON, template) – > HTML

I'm using a Java framework (actually a playback framework, but I don't think it's framework specific)

I've seen many similar problems. The latest and most helpful one is: templating language for both client side and server side rendering

I very much agree with the author's clear competitors, such as beard and Google closure template, will not cut it (see this post for the reason)

requirement:

>Must: client rendering > must: client cache template file > nice: client 'compile and execute the template file multiple times at a time to fast JavaScript code > must: server-side rendering > nice: native Java implementation

I saw a bunch of Posts and suggested using node JS for server - side templates Although this will certainly work (underline template, handlebarsjs and EJS all work normally), I'm trying to see how to put node JS communicates / combines / integrates with Java. After all, it is still a Java framework that needs to output JSON

I've read some posts about JVM and node JS (via HTTP or JNDI) However, there seems to be no library now, let alone tested

So in order to sort out these things, which client template engines do you suggest to run in Java (or have some rings that can be called from the JVM)? And if "hook" happens to be node JS, so what kind of communication / library do you recommend?

Solution

I'm going to do a moustache now and look forward to handlebars Java implementation of JS

Edit – April 2012

OK, update this for future reference:

>I outsource the server-side template to node js. > Java and node implemented using sockets JS (see: sending data from node.js to Java using sockets, where do I have ideas) > from now on, I only need a client lib (or better JavaScript running on the client and server), and I can choose more freely Getting used to the beard, I chose Hogan analyzer (by the twitter guy)( http://twitter.github.com/hogan.js/ )

100% dry (even client mixins and I18N bundles come from the same source. In addition, hogan can pre compile the server-side template and open the connection with the client so that the client no longer needs to parse the template when connecting for the first time

Is it fast? Lightning

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>