jonschlinkert / templates

System for creating and managing view collections, rendering, engines, routes and more. See the "dev" branch for most recent updates.
MIT License
60 stars 9 forks source link

Context #20

Closed doowb closed 8 years ago

doowb commented 8 years ago

This addresses #19 and also passes current and new tests. This changes the signature of app.context to pass the view in as the first parameter. This let's us by default to do the following for merging context:

var ctx = utils.merge({}, app.cache.data, view.locals, view.data, locals);

It also lets the user override all the functionality with the options.context function:

app.option('context', function(view, locals) {
  return merge({}, this.cache.data, view.context(locals));
});

I think this is the correct way to merge context, but I wanted to open a PR for discussion. This will need to be updated in assemble-render-file too.

jonschlinkert commented 8 years ago

this is good, I like how you did everything, makes sense. I'm good with merging/publishing