klaytonfaria
2/6/2014 - 6:31 PM

From https://github.com/linkedin/dustjs-helpers/pull/57

dust.scopes = {};

dust.helpers.addToScope = function(chunk, context, bodies, params) {
  return chunk.capture(bodies.block, context, function(out, chunk) {
    var parts = params.key.split("."), 
         scopeKey = parts[0], 
         key = parts[1], 
         scope = dust.scopes[scopeKey] || {};

    scope[key] = out;
    dust.scopes[scopeKey] = scope;

    chunk.end();
  });
};