Skip to content

Commit 52f1cde

Browse files
committed
liquid filters to universal
1 parent 6a23f66 commit 52f1cde

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/Engines/Liquid.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ export default class Liquid extends TemplateEngine {
2626

2727
this.argLexer = moo.compile(Liquid.argumentLexerOptions);
2828
this.cacheable = true;
29+
30+
this.filters = eleventyConfig.getFilters({
31+
lang: "liquid",
32+
async: false,
33+
});
2934
}
3035

3136
setLibrary(override) {
3237
// warning, the include syntax supported here does not exactly match what Jekyll uses.
3338
this.liquidLib = override || new LiquidJs(this.getLiquidOptions());
3439
this.setEngineLib(this.liquidLib);
3540

36-
this.addFilters(this.config.liquidFilters);
41+
this.addFilters(this.filters);
3742

3843
// TODO these all go to the same place (addTag), add warnings for overwrites
3944
this.addCustomTags(this.config.liquidTags);

src/UserConfig.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,21 @@ class UserConfig {
384384
* Filters
385385
*/
386386

387+
/**
388+
* @deprecated Use {@link addFilter} instead, with options.langs set to ["liquid"] if you wish it to be scoped.
389+
*/
387390
addLiquidFilter(name, callback) {
388-
this.#add(this.liquid.filters, name, callback, {
389-
description: "Liquid Filter",
390-
functionName: "addLiquidFilter",
391-
});
391+
this.logger.warn(
392+
'`addLiquidFilter` is deprecated and will be removed in a future release.\
393+
Use `addFilter` instead, with options.lang set to ["liquid"] if you wish it to be scoped.',
394+
);
395+
this.addFilter(
396+
name,
397+
callback,
398+
{
399+
langs: ["liquid"],
400+
},
401+
);
392402
}
393403

394404
/**
@@ -459,16 +469,19 @@ class UserConfig {
459469
async,
460470
});
461471

462-
this.addLiquidFilter(name, callback);
463472
this.addJavaScriptFilter(name, callback);
464473
}
465474

466-
// Liquid, Nunjucks, and JS only
467475
/**
468-
* @deprecated Pass an async function to `addFilter` instead.
476+
* Perhaps this should be deprecated.
477+
* addAsyncFilter("...", function() {return Promise}) and
478+
* addFilter("...", function() {return Promise}, {async: true})
479+
* are the same.
469480
*/
470481
addAsyncFilter(name, callback) {
471-
this.addFilter(name, callback);
482+
this.addFilter(name, callback, {
483+
async: true,
484+
});
472485
}
473486

474487
/*
@@ -1267,7 +1280,6 @@ class UserConfig {
12671280
// Liquid
12681281
liquidOptions: this.liquid.options,
12691282
liquidTags: this.liquid.tags,
1270-
liquidFilters: this.liquid.filters,
12711283
liquidShortcodes: this.liquid.shortcodes,
12721284
liquidPairedShortcodes: this.liquid.pairedShortcodes,
12731285
liquidParameterParsing: this.liquid.parameterParsing,

0 commit comments

Comments
 (0)