// This is a mechanism for quickly rendering templates which is Ember aware // templates are highly compatible with Ember so you don't need to worry about calling "get" // and computed properties function, additionally it uses stringParams like Ember does // compat with ie8 in case this gets picked up elsewhere const objectCreate = Object.create || function(parent) { function F() {} F.prototype = parent; return new F(); }; const RawHandlebars = Handlebars.create(); RawHandlebars.helper = function() {}; RawHandlebars.helpers = objectCreate(Handlebars.helpers); RawHandlebars.helpers['get'] = function(context, options) { var firstContext = options.contexts[0]; var val = firstContext[context]; if (val && val.isDescriptor) { return Em.get(firstContext, context); } val = val === undefined ? Em.get(firstContext, context): val; return val; }; // adds compatability so this works with stringParams function stringCompatHelper(fn) { const old = RawHandlebars.helpers[fn]; RawHandlebars.helpers[fn] = function(context,options) { return old.apply(this, [ RawHandlebars.helpers.get(context,options), options ]); }; }; // #each .. in support (as format is transformed to this) RawHandlebars.registerHelper('each', function(localName,inKeyword,contextName,options){ var list = Em.get(this, contextName); var output = []; var innerContext = objectCreate(this); for (var i=0; i