mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Support for Raw Handlebars and helpers in Ember 1.13
This commit is contained in:
@ -55,12 +55,6 @@ function resolveParams(ctx, options) {
|
||||
}
|
||||
|
||||
export function registerUnbound(name, fn) {
|
||||
if (Ember.Helper) {
|
||||
_helpers[name] = Ember.Helper.helper(function() {
|
||||
// TODO: Allow newer ember to use helpers
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const func = function(property, options) {
|
||||
if (options.types && (options.types[0] === "ID" || options.types[0] === "PathExpression")) {
|
||||
@ -70,6 +64,14 @@ export function registerUnbound(name, fn) {
|
||||
return fn.call(this, property, resolveParams(this, options));
|
||||
};
|
||||
|
||||
if (Ember.Helper) {
|
||||
_helpers[name] = Ember.Helper.extend({
|
||||
compute: (params, args) => fn(params[0], args)
|
||||
});
|
||||
Handlebars.registerHelper(name, func);
|
||||
return;
|
||||
}
|
||||
|
||||
Handlebars.registerHelper(name, func);
|
||||
Ember.Handlebars.registerHelper(name, func);
|
||||
}
|
||||
|
@ -132,6 +132,12 @@ export function buildResolver(baseName) {
|
||||
},
|
||||
|
||||
resolveTemplate(parsedName) {
|
||||
let fullName = parsedName.fullNameWithoutType;
|
||||
if (fullName.indexOf('.raw') !== -1) {
|
||||
return Ember.TEMPLATES[fullName] ||
|
||||
Ember.TEMPLATES[fullName.replace(/\.raw$/, '')];
|
||||
}
|
||||
|
||||
return this.findPluginMobileTemplate(parsedName) ||
|
||||
this.findPluginTemplate(parsedName) ||
|
||||
this.findMobileTemplate(parsedName) ||
|
||||
|
Reference in New Issue
Block a user