Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery templates on the server side

Has anyone tried to use jQuery templates (or any other JavaScript based templating) on the server side with something like env.js?

I'm considering attempting it to see what benefits could be gained by being able to render identical templates on either the client or server side of a web application, but I was hoping someone might already have some experience, or know of an existing project doing this. I'd be particularly interested to know about any performance issues I might encounter compared to some more traditional templating engine.

To recap : Has anyone ever used jquery templates on the server site? If so, were there any performance issues, or other problems I might run into?

like image 517
Matt Sheppard Avatar asked Nov 16 '10 22:11

Matt Sheppard


1 Answers

env.js is unnecessary.

<plug shameless="true">

I am in the process of specing and re-implementing JQuery templates to allow them to be used independently of the DOM. See https://github.com/mikesamuel/jquery-jquery-tmpl-proposal for code, and demos. The spec is available at http://wiki.jqueryui.com/w/page/37898666/Template and it says:

Text-centric rather than DOM dependent. Status: Done. See section 12 implementations. foo${bar} translates to something very similar to function (data, options) { return "foo" + bar; } modulo some dethunking of bar

...

This will allow to use this template engine in server side javascript environment, such as node.js, or java/rhino

I would love feedback and can help you get started.

</plug>

like image 190
Mike Samuel Avatar answered Oct 18 '22 15:10

Mike Samuel