REFACTOR: Split off raw handlebars helpers from compiler

This allows us to compile without Ember being present
This commit is contained in:
Robin Ward
2019-11-01 11:01:16 -04:00
parent 4e07f725c6
commit 785ebb674d
5 changed files with 73 additions and 87 deletions

View File

@ -1,4 +1,4 @@
import { rawGet } from "discourse-common/lib/raw-handlebars";
import { get } from "@ember/object";
export function htmlHelper(fn) {
return Ember.Helper.helper(function(...args) {
@ -10,6 +10,17 @@ export function htmlHelper(fn) {
const _helpers = {};
function rawGet(ctx, property, options) {
if (options.types && options.data.view) {
var view = options.data.view;
return view.getStream
? view.getStream(property).value()
: view.getAttr(property);
} else {
return get(ctx, property);
}
}
export function registerHelper(name, fn) {
_helpers[name] = Ember.Helper.helper(fn);
}