Skip to content
Permalink
Browse files

Upgrade handlebars (#8675)

* Upgrade Handlebars to 4.3.0

* Upgrade Handlebars to the latest version
  • Loading branch information
eviltrout committed Jan 7, 2020
1 parent b51b2cc commit abff3716bacdc7acb1c7639b90207b5dc69cc6bd
@@ -1,5 +1,6 @@
import { get } from "@ember/object";
import Helper from "@ember/component/helper";
import RawHandlebars from "discourse-common/lib/raw-handlebars";

export function makeArray(obj) {
if (obj === null || obj === undefined) {
@@ -88,5 +89,5 @@ export function registerUnbound(name, fn) {
_helpers[name] = Helper.extend({
compute: (params, args) => fn(...params, args)
});
Handlebars.registerHelper(name, func);
RawHandlebars.registerHelper(name, func);
}
@@ -1,14 +1,23 @@
import { get } from "@ember/object";

export function registerRawHelpers(hbs, handlebarsClass) {
hbs.helper = function() {};
hbs.helpers = Object.create(handlebarsClass.helpers);
if (!hbs.helpers) {
hbs.helpers = Object.create(handlebarsClass.helpers);
}

hbs.helpers["get"] = function(context, options) {
var firstContext = options.contexts[0];
var val = firstContext[context];
if (!context || !options.contexts) {
return;
}

if (typeof context !== "string") {
return context;
}

let firstContext = options.contexts[0];
let val = firstContext[context];

if (context.indexOf("controller.") === 0) {
if (context.toString().indexOf("controller.") === 0) {
context = context.slice(context.indexOf(".") + 1);
}

@@ -1,6 +1,7 @@
import { rawConnectorsFor } from "discourse/lib/plugin-connectors";
import RawHandlebars from "discourse-common/lib/raw-handlebars";

Handlebars.registerHelper("raw-plugin-outlet", function(args) {
RawHandlebars.registerHelper("raw-plugin-outlet", function(args) {
const connectors = rawConnectorsFor(args.hash.name);
if (connectors.length) {
const output = connectors.map(c => c.template({ context: this }));
@@ -6,6 +6,7 @@ pre-commit:
run: bundle exec rubocop {staged_files}
eslint:
glob: "*.{js,es6}"
exclude: 'vendor/*'
run: yarn eslint --ext .es6 -f compact {staged_files}
yaml-syntax:
glob: "*.{yaml,yml}"
@@ -11,8 +11,9 @@
"bootbox": "3.2.0",
"bootstrap": "v3.4.1",
"chart.js": "2.9.3",
"eslint-plugin-lodash": "^6.0.0",
"favcount": "https://github.com/chrishunt/favcount",
"handlebars": "^4.1.2",
"handlebars": "^4.3.0",
"highlight.js": "https://github.com/highlightjs/highlight.js",
"htmlparser": "https://github.com/tautologistics/node-htmlparser",
"intersection-observer": "^0.5.1",

0 comments on commit abff371

Please sign in to comment.
You can’t perform that action at this time.