mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +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 () {
|
||||
const self = this;
|
||||
return function (...args) {
|
||||
const { fn } = args.pop();
|
||||
const { fn, data } = args.pop();
|
||||
let contents;
|
||||
|
||||
if (fn) {
|
||||
contents = stripIndent(fn(this));
|
||||
contents = stripIndent(fn(data));
|
||||
} else {
|
||||
let tpath = args.shift();
|
||||
tpath = self._parsePath(tpath, this.local, 'md');
|
||||
tpath = self._parsePath(tpath, data.root.local, 'md');
|
||||
|
||||
contents = self._template(tpath);
|
||||
}
|
||||
|
||||
contents = markdown('full', contents, this);
|
||||
contents = markdown('full', contents, data);
|
||||
|
||||
return new handlebars.SafeString(contents);
|
||||
};
|
||||
@ -213,12 +213,12 @@ class Injectables {
|
||||
import () {
|
||||
const self = this;
|
||||
return function (tpath, ...args) {
|
||||
const { hash } = args.pop();
|
||||
const { hash, data } = args.pop();
|
||||
const value = args.shift();
|
||||
const context = handlebars.createFrame(value || this);
|
||||
const context = handlebars.createFrame(value || data);
|
||||
Object.assign(context, hash || {});
|
||||
|
||||
tpath = self._parsePath(tpath, this.local, 'hbs');
|
||||
tpath = self._parsePath(tpath, data.root.local, 'hbs');
|
||||
|
||||
try {
|
||||
const contents = self._template(tpath, handlebars.compile)(context);
|
||||
@ -233,8 +233,8 @@ class Injectables {
|
||||
icon () {
|
||||
const self = this;
|
||||
return function (name, ...args) {
|
||||
const { hash } = args.pop();
|
||||
const tpath = path.join(this.local.root, 'svg', name + '.svg');
|
||||
const { hash, data } = args.pop();
|
||||
const tpath = path.join(data.root.local.root, 'svg', name + '.svg');
|
||||
|
||||
try {
|
||||
const contents = self._template(tpath, (s) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user