Enable serveClient() accept second parameters and forward it to view engine #341

Closed
wants to merge 5 commits into from

3 participants

@lge88

Make it similar to Express's render method:

res.render('main', [locals]);

In socketstream:

res.serveClient('main', {
  title : 'main',
  version : '1.0',
  ...
});

Corresponding view engine wrappers need to be modified to enable this feature. For example, in ss-jade/wrapper.js, compile function needs to be modified.

compile: function(path, options, cb) {

  // locals now can be accessed by options.locals. 
  var locals = (options && options.locals) ? options.locals : {};
  ...

  var output = parser(locals);
  cb(output);
}
@lge88 lge88 referenced this pull request in socketstream/ss-jade Jan 19, 2013
Open

make ss-jade accept locals from serveClient #5

@owenb

Hey there

Sorry for taking an age to get back to you. I was considering this request for some time, then got really busy with other work and, during the last month, 0.4 development.

As the first alpha version of 0.4 will be out very soon, I no longer want to make any changes to 0.3 - unless it's a critical bug or something similar.

However, your elegant solution has inspired me to do something similar with 0.4. What it will be exactly, I'm not sure yet (I was working all day yesterday on the new asset builder), but rest assured I see the need to render jade file server-side and I'll make sure it's possible.

Again, sorry for taking so long to reply.

Cheers,

Owen

@owenb owenb closed this Apr 14, 2013
@lge88

Sounds good. I am looking forward to seeing the 0.4 version!

@helozjisky

https://github.com/socketstream/ss-jade

ss.client.formatters.add(require('ss-jade'), {locals: {countries: {}}});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment