chaplinjs / chaplin

HTML5 application architecture using Backbone.js
http://chaplinjs.org
Other
2.85k stars 232 forks source link

How can i port Chaplin to work in node.js server side? #660

Open haohello opened 11 years ago

haohello commented 11 years ago

After reading the source code of Chaplin, I've got some idea to port the router related class to node.js, however as for the view rendering, there will be a lot of work to be done to get it working in node.js. Mostly about having the chaplin to work asynchronously for the view rendering, and notify the express router function to respond the constructed html to the client once it finishes the rendering for various views.

The other backbone related project which can be working on the server side node.js environment is backbone.layoutmanager, it uses jquery deferred or underscore deferred to accomplish such kind of asynchronous handling.

Please let me know if you've got any ideas to get this working in node.js.

chrisabrams commented 11 years ago

I've got a very large portion of Chaplin working with Node.js: Views, Models (with validation), Controllers, Routes, Templates. I have no idea if it is the most efficient way but I would definitely be open to discussing this more.

haohello commented 11 years ago

@chrisabrams Could you please share your code with me and let's see how to optimize it?

YAndrew91 commented 11 years ago

+1, I also have a similar task now, so it would be very helpful to see any example

haohello commented 11 years ago

@chrisabrams I saw your project The-Tramp works on node.js, however there is one thing that I don't like is the way that you are using jquery and jsdom on the server side to build html doms. Well, i'm going the another route with backbone.layoutmanager which is a Backbone.View descendant, and I rewrote the Chaplin.View to inherit from the backbone.layoutmanager, it works great for me.

Since I'm currently developing a cms, I might open source it once it is fully workable.

chrisabrams commented 11 years ago

Looking forward to seeing your example.

nickdima commented 11 years ago

I'm also interested on this. Let's keep this thread updated with our findings. And maybe more of us could work on a common solution.

haohello commented 10 years ago

Here is my version of writing backbone.js (chaplin.js) apps on the server side