Client-side templating language with java compiler as well (DRY templating)

后端 未结 1 2003
一向
一向 2020-12-14 23:48

I want to be able to define templates once and use them to render html from both the server-side as well as the client-side. (DRY principle and all that)

The API tha

相关标签:
1条回答
  • 2020-12-15 00:23

    I'm going for Mustache for now and anticipating a java implementation for Handlebars.js. Once that exists, the refactoring-path shouldn't be that steep.

    EDIT - april 2012

    Ok, updating this for future reference:

    • I'm outsourcing server-side templating to Node.js.
    • communication between java and node.js implemented using sockets. (see: Sending data from node.js to Java using sockets for where I got the idea)
    • Since now I only need a client-lib (or better one that runs in javascript on both client and server-side using node) I can choose more freely. Having become accustomed to Mustache, I've chosen the Hogan parser (by the Twitter guys) ( http://twitter.github.com/hogan.js/ )

    100% DRY (even the client-side mixins and i18N-bundles come from the same source. Moreover, Hogan can precompile the templates server-side and open a connection to the client so the client doesn't have to parse the template anymore on first connect.

    Is it fast? Lightning...

    0 讨论(0)
提交回复
热议问题