Skip to content

Commit

Permalink
Fix regressions for liquidjs@10 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 6, 2022
1 parent 078b675 commit a40c631
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"is-glob": "^4.0.3",
"iso-639-1": "^2.1.15",
"kleur": "^4.1.5",
"liquidjs": "9.41.0",
"liquidjs": "^10.2.0",
"lodash": "^4.17.21",
"luxon": "^3.1.0",
"markdown-it": "^13.0.1",
Expand Down
16 changes: 8 additions & 8 deletions src/Engines/Liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,19 @@ class Liquid extends TemplateEngine {
this.name = tagToken.name;
this.args = tagToken.args;
},
render: function* (ctx) {
render: function* (ctx, emitter) {
let rawArgs = Liquid.parseArguments(_t.argLexer, this.args);
let argArray = [];
for (let arg of rawArgs) {
let b = yield liquidEngine.evalValue(arg, ctx);
let b = yield liquidEngine.evalValue(arg, ctx.environments);
argArray.push(b);
}

let ret = shortcodeFn.call(
let ret = yield shortcodeFn.call(
Liquid._normalizeShortcodeScope(ctx),
...argArray
);
yield ret;
// emitter.write(ret);
return ret;
},
};
Expand All @@ -183,11 +183,11 @@ class Liquid extends TemplateEngine {

stream.start();
},
render: function* (ctx) {
render: function* (ctx, emitter) {
let rawArgs = Liquid.parseArguments(_t.argLexer, this.args);
let argArray = [];
for (let arg of rawArgs) {
let b = yield liquidEngine.evalValue(arg, ctx);
let b = yield liquidEngine.evalValue(arg, ctx.environments);
argArray.push(b);
}

Expand All @@ -196,12 +196,12 @@ class Liquid extends TemplateEngine {
ctx
);

let ret = shortcodeFn.call(
let ret = yield shortcodeFn.call(
Liquid._normalizeShortcodeScope(ctx),
html,
...argArray
);
yield ret;
// emitter.write(ret);
return ret;
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/RenderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {
let rawArgs = Liquid.parseArguments(null, this.args);
let argArray = [];
for (let arg of rawArgs) {
let b = yield liquidEngine.evalValue(arg, ctx);
let b = yield liquidEngine.evalValue(arg, ctx.environments);
argArray.push(b);
}

Expand Down
12 changes: 6 additions & 6 deletions test/TemplateRenderLiquidTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ test("Liquid Custom Tag prefixWithZach", async (t) => {
parse: function (tagToken, remainTokens) {
this.str = tagToken.args; // name
},
render: function (scope, hash) {
var str = liquidEngine.evalValueSync(this.str, scope); // 'alice'
render: function (ctx, hash) {
var str = liquidEngine.evalValueSync(this.str, ctx.environments); // 'alice'
return Promise.resolve("Zach" + str); // 'Alice'
},
};
Expand All @@ -250,8 +250,8 @@ test("Liquid Custom Tag postfixWithZach", async (t) => {
parse: function (tagToken, remainTokens) {
this.str = tagToken.args;
},
render: async function (scope, hash) {
var str = await liquidEngine.evalValue(this.str, scope);
render: async function (ctx, hash) {
var str = await liquidEngine.evalValue(this.str, ctx.environments);
return Promise.resolve(str + "Zach");
},
};
Expand Down Expand Up @@ -300,8 +300,8 @@ test("Liquid addTags", async (t) => {
parse: function (tagToken, remainTokens) {
this.str = tagToken.args;
},
render: async function (scope, hash) {
var str = await liquidEngine.evalValue(this.str, scope);
render: async function (ctx, hash) {
var str = await liquidEngine.evalValue(this.str, ctx.environments);
return Promise.resolve(str + "Zach");
},
};
Expand Down

0 comments on commit a40c631

Please sign in to comment.