Live data from Hacker News

Rendr - Use Backbone on both the server and client

github.com

11–20 of 35 posts

Re: Rendr - Use Backbone on both the server and client

#11
This is pretty cool. I've been playing around with a variety of JS frameworks recently and code sharing is probably my 2nd favorite thing about meteor. Anybody know if these guys are hiring? My school's big interview day is on Thursday and airbnb's front-end stack looks appealing.

Re: Rendr - Use Backbone on both the server and client

#12
post #9

I don't like the idea of rendering client code in the server.

Don't think of it as client or server code. Think of it as presentation code. And it happens to run on both the server and browser.

Though, don't write your business code in javascript. Hell to maintain.

Re: Rendr - Use Backbone on both the server and client

#13
post #9

I don't like the idea of rendering client code in the server.

If you can do it without code duplication, why not just consider it a kind of caching? That's how it seems to be used here: as an optimization.

If your definition of the JSON to HTML transformation is declarative, it makes sense to allow the server to do it for the data that's available to it.

The web has a semi-long history of "dumb clients," and that means the server has to be able to do the rendering. There are some pretty good reasons for this, and projects like Rendr try to make it as easy as possible. Seems good to me!

Re: Rendr - Use Backbone on both the server and client

#16
My brother released a very similar project about 8 months ago.[1] He never did properly announce or document it so it's no surprise that nobody else is using it.

Of course, it's not like rendr has any real documentation, either.

However it has been working very well for us, so it is validation of the rendr approach.

A quick glance at their documentation indicates a very similar design, comparing the two projects should be instructive.

1: https://github.com/wvl/highbrow

Re: Rendr - Use Backbone on both the server and client

#17
post #15

Wow, their samples sure look like Batman.js. Also, I'm a fan of them for going with CoffeeScript, they have taste. But seriously, looks very much like Shopify's batman.js http://batmanjs.org

They're both written in coffeescript, and they're both written about the same time so have very similar influences.

I think most of the similarities you see stem from those two points.

But there are some massive differences:

- batman.js is Rails-style MVC, rendr is based on Backbone so you must supply your own controllers. A good argument can be made that Rails is not truely MVC, but it at least attempts to do so. rendr is MV.

- RENDR runs and renders on the server. batman.js relies on a Rails or REST app on the server.

- rendr is based on Backbone.js and Express, batman.js isn't

Re: Rendr - Use Backbone on both the server and client

#18

My brother released a very similar project about 8 months ago.[1] He never did properly announce or document it so it's no surprise that nobody else is using it. Of course, it's not like rendr has any real documentation, either. However it has been working very well for us, so it is validation of the rendr approach. A quick glance at their documentation indicates a very similar design, comparing the two projects shou…

I looked a little bit more at the rendr source, and one thing that immediately jumps out at me is the code BaseView#getTemplateData[1] which very tightly couples the model & views together. You should totally steal highbrow's ViewModel code, which is very sweet. (But you might want to come up with a better name). Rather than passing @model.toJSON() as template data, highbrow creates a ViewModel from the model or collection or out of thin air, and passes that in as template data.

Here's a typical ViewModel definition (in JS):

    foo.vm.Resource = highbrow.ViewModel.extend({
      lastUpdated: function() {
        return moment(this.model.get('modifiedAt')).fromNow();
      }
    });
    foo.vm.Resource.attrs(['name', 'content']);
This shows the main two features of ViewModel's: a whitelist of attrs that the template can access directly, and a set of functions that would otherwise end up polluting your model with view side code.

This decoupling dramatically improves the structure of our applications, without introducing Rails style controllers which are also totally misnamed in my opinion. Rails controllers are essentially two things: routers and MV-shims. Splitting the two makes for much improved program structure.

1: https://github.com/airbnb/rendr/blob/master/shared/base/view...

2: https://github.com/wvl/highbrow/blob/master/src/view-model.c...

Re: Rendr - Use Backbone on both the server and client

#19

My brother released a very similar project about 8 months ago.[1] He never did properly announce or document it so it's no surprise that nobody else is using it. Of course, it's not like rendr has any real documentation, either. However it has been working very well for us, so it is validation of the rendr approach. A quick glance at their documentation indicates a very similar design, comparing the two projects shou…

Here's a sample app: https://github.com/wvl/twumblook

Re: Rendr - Use Backbone on both the server and client

#20

My brother released a very similar project about 8 months ago.[1] He never did properly announce or document it so it's no surprise that nobody else is using it. Of course, it's not like rendr has any real documentation, either. However it has been working very well for us, so it is validation of the rendr approach. A quick glance at their documentation indicates a very similar design, comparing the two projects shou…

I think this design goal:

    * Minimize if (server) {...} else {…}
was unfortunate. A grep of the highbrow source code indicates about 10 instances of that pattern, so I don't think there's a need for a separate base/server/client directory structure like rendr has, I think that creates artificial distinctions. It may be because I'm used to reading the highbrow source (because that's the only documentation :), but I find those if/else blocks to be very illuminating.
Post reply on HN