From 2ca0a307de06e49e28704245a52b353828e2bb3f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 17 Dec 2014 10:05:38 -0500 Subject: [PATCH] FIX: When using `{{avatar}}` within autocomplete --- .../discourse/helpers/register-unbound.js.es6 | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/helpers/register-unbound.js.es6 b/app/assets/javascripts/discourse/helpers/register-unbound.js.es6 index d02c20770e3..5296f4d5a8f 100644 --- a/app/assets/javascripts/discourse/helpers/register-unbound.js.es6 +++ b/app/assets/javascripts/discourse/helpers/register-unbound.js.es6 @@ -3,7 +3,7 @@ var get = Discourse.EmberCompatHandlebars.get; export default function registerUnbound(name, fn) { Handlebars.registerHelper(name, function(property, options) { - if (options.types[0] === "ID") { + if (options.types && options.types[0] === "ID") { property = get(this, property, options); } @@ -12,14 +12,18 @@ export default function registerUnbound(name, fn) { if (hash) { var self = this; - Ember.keys(options.hash).forEach(function(k) { - var type = options.hashTypes[k]; - if (type === "STRING") { - params[k] = hash[k]; - } else if (type === "ID") { - params[k] = get(self, hash[k], options); - } - }); + if (options.hashTypes) { + Ember.keys(hash).forEach(function(k) { + var type = options.hashTypes[k]; + if (type === "STRING") { + params[k] = hash[k]; + } else if (type === "ID") { + params[k] = get(self, hash[k], options); + } + }); + } else { + params = hash; + } } return fn(property, params);