REFACTOR: Remove Ember.get

This commit is contained in:
Robin Ward
2019-10-31 16:28:10 -04:00
parent 89f602f66b
commit 640a05c4ee
31 changed files with 84 additions and 56 deletions
@@ -1,4 +1,4 @@
import { get } from "discourse-common/lib/raw-handlebars";
import { rawGet } from "discourse-common/lib/raw-handlebars";
export function htmlHelper(fn) {
return Ember.Helper.helper(function(...args) {
@@ -39,7 +39,7 @@ function resolveParams(ctx, options) {
) {
params[k] = hash[k];
} else if (type === "ID" || type === "PathExpression") {
params[k] = get(ctx, hash[k], options);
params[k] = rawGet(ctx, hash[k], options);
}
});
} else {
@@ -59,7 +59,7 @@ export function registerUnbound(name, fn) {
options.types &&
(options.types[i] === "ID" || options.types[i] === "PathExpression")
) {
properties[i] = get(this, properties[i], options);
properties[i] = rawGet(this, properties[i], options);
}
}
@@ -1,3 +1,5 @@
import { get } from "@ember/object";
// 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
@@ -24,7 +26,7 @@ RawHandlebars.helpers["get"] = function(context, options) {
context = context.slice(context.indexOf(".") + 1);
}
return val === undefined ? Ember.get(firstContext, context) : val;
return val === undefined ? get(firstContext, context) : val;
};
// adds compatability so this works with stringParams
@@ -45,7 +47,7 @@ RawHandlebars.registerHelper("each", function(
contextName,
options
) {
var list = Ember.get(this, contextName);
var list = get(this, contextName);
var output = [];
var innerContext = objectCreate(this);
for (var i = 0; i < list.length; i++) {
@@ -178,7 +180,7 @@ RawHandlebars.get = function(ctx, property, options) {
? view.getStream(property).value()
: view.getAttr(property);
} else {
return Ember.get(ctx, property);
return get(ctx, property);
}
};
@@ -194,7 +196,7 @@ export function compile() {
return RawHandlebars.compile.apply(this, arguments);
}
export function get() {
export function rawGet() {
return RawHandlebars.get.apply(this, arguments);
}