ember.js - extending EmberDefaultResolver with Ember-App-Kit -
i'm making custom resolver based on pattern below robin ward [ video / 15sec] trick have mobile device "mob_template.hbs" first before loading "template.hbs"
app.resolver = emberdefaultresolver.extend({ resolvetemplate: function(parsedname){ var t = this._super(parsedname); if app.mobileactive){ return this._super('mob_' + parsedname) || t; } return t; } });
however i'm using ember app kit, uses special version of resolver:
i can't tell what's going on in there or need produce similar functionality. have idea?
i've tried results in nothing being resolved:
var app = ember.application.extend({ //... resolver: ember.defaultresolver.extend({ resolve: function(fullname) { var parsedname = this.parsename(fullname), resolvemethodname = parsedname.resolvemethodname; if (!(parsedname.name && parsedname.type)) { throw new typeerror("invalid fullname: `" + fullname + "`, must of form `type:name` "); } if (this[resolvemethodname]) { if (window.screen_type == 'mobile'){ var resolved = this[resolvemethodname](parsedname + '_mobile'); } else{ var resolved = this[resolvemethodname](parsedname); } if (resolved) { return resolved; } } return this.resolveother(parsedname); }, }) });
apparently parsedname not string of template name in eak resolver, has props representing template name though, parsedname.fullnamewithouttype being 1 target:
var customresolver = resolver.extend({ resolvetemplate: function(parsedname){ var resolve = this._super(parsedname); if (['foo','bar'].indexof(window.special_prop) > -1){ var orig__parsedname_name = parsedname.name; parsedname.name = parsedname.name + '_' + window.special_prop; parsedname.fullname = parsedname.fullname + '_' + window.special_prop; parsedname.fullnamewithouttype = parsedname.fullnamewithouttype + '_' + window.special_prop; resolve = this._super(parsedname) || resolve; } return resolve; } }); var app = ember.application.extend({ //... resolver: customresolver });
Comments
Post a Comment