FIX: Backwards compatibility for controller in raw templates

This commit is contained in:
Robin Ward 2016-12-21 16:38:57 -05:00
parent 1463e9ae46
commit 89bdca9c8c

View File

@ -1,3 +1,5 @@
import deprecated from 'discourse-common/lib/deprecated';
// 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
@ -18,6 +20,11 @@ RawHandlebars.helpers['get'] = function(context, options) {
var firstContext = options.contexts[0];
var val = firstContext[context];
if (context.indexOf('controller') === 0) {
deprecated("Don't `use controller` in raw templates");
context = context.replace(/^controller\./, '');
}
if (val && val.isDescriptor) { return Em.get(firstContext, context); }
val = val === undefined ? Em.get(firstContext, context): val;
return val;