mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-02-07 10:16:16 +00:00
Fix bugs with helpers accessing scoped data
This commit is contained in:
parent
640c3ac1a8
commit
065dd4ad79
@ -192,19 +192,19 @@ class Injectables {
|
|||||||
markdown () {
|
markdown () {
|
||||||
const self = this;
|
const self = this;
|
||||||
return function (...args) {
|
return function (...args) {
|
||||||
const { fn } = args.pop();
|
const { fn, data } = args.pop();
|
||||||
let contents;
|
let contents;
|
||||||
|
|
||||||
if (fn) {
|
if (fn) {
|
||||||
contents = stripIndent(fn(this));
|
contents = stripIndent(fn(data));
|
||||||
} else {
|
} else {
|
||||||
let tpath = args.shift();
|
let tpath = args.shift();
|
||||||
tpath = self._parsePath(tpath, this.local, 'md');
|
tpath = self._parsePath(tpath, data.root.local, 'md');
|
||||||
|
|
||||||
contents = self._template(tpath);
|
contents = self._template(tpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
contents = markdown('full', contents, this);
|
contents = markdown('full', contents, data);
|
||||||
|
|
||||||
return new handlebars.SafeString(contents);
|
return new handlebars.SafeString(contents);
|
||||||
};
|
};
|
||||||
@ -213,12 +213,12 @@ class Injectables {
|
|||||||
import () {
|
import () {
|
||||||
const self = this;
|
const self = this;
|
||||||
return function (tpath, ...args) {
|
return function (tpath, ...args) {
|
||||||
const { hash } = args.pop();
|
const { hash, data } = args.pop();
|
||||||
const value = args.shift();
|
const value = args.shift();
|
||||||
const context = handlebars.createFrame(value || this);
|
const context = handlebars.createFrame(value || data);
|
||||||
Object.assign(context, hash || {});
|
Object.assign(context, hash || {});
|
||||||
|
|
||||||
tpath = self._parsePath(tpath, this.local, 'hbs');
|
tpath = self._parsePath(tpath, data.root.local, 'hbs');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const contents = self._template(tpath, handlebars.compile)(context);
|
const contents = self._template(tpath, handlebars.compile)(context);
|
||||||
@ -233,8 +233,8 @@ class Injectables {
|
|||||||
icon () {
|
icon () {
|
||||||
const self = this;
|
const self = this;
|
||||||
return function (name, ...args) {
|
return function (name, ...args) {
|
||||||
const { hash } = args.pop();
|
const { hash, data } = args.pop();
|
||||||
const tpath = path.join(this.local.root, 'svg', name + '.svg');
|
const tpath = path.join(data.root.local.root, 'svg', name + '.svg');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const contents = self._template(tpath, (s) =>
|
const contents = self._template(tpath, (s) =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user