Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access built-in filters? #188

Closed
pdehaan opened this issue Feb 13, 2020 · 2 comments
Closed

Access built-in filters? #188

pdehaan opened this issue Feb 13, 2020 · 2 comments

Comments

@pdehaan
Copy link
Contributor

pdehaan commented Feb 13, 2020

Is there a way to access the built-in liquidjs filters from a liquidjs class/instance?

I'm using eleventy, and wanted to try sharing filters between liquidjs and nunjucks.

I tried the following, but didn't see any references to filters and am not sure I understand where the filters are stored internally, or if they're private:

const util = require("util");

const liquid = require("liquidjs");

console.log(util.inspect(liquid));
console.log(util.inspect(new liquid()));
@harttle
Copy link
Owner

harttle commented Feb 14, 2020

Filters are registered to the impl static property of the Filter class(in src/template/filter/filter.ts), which is referenced as a closure variable by Liquid. Thus you cannot get the set of filters by Liquid class or instance, currently.

Thanks to this issue I find out that during every Liquid construction builtin tags/filters are re-registered, and every liquid instance always has the same set of tags/filters despite of the fact that .registerFilter() and .registerTag() are instance methods.

Definitely we should make the set of filters and tags properties of Liquid, are you interested to make a PR? I can help for the test cases.

@harttle harttle closed this as completed in df8a919 Mar 2, 2020
harttle pushed a commit that referenced this issue Mar 2, 2020
# [9.9.0](v9.8.0...v9.9.0) (2020-03-02)

### Features

* move filters/tags to instances, fixes [#188](#188) ([df8a919](df8a919))
@harttle
Copy link
Owner

harttle commented Mar 2, 2020

🎉 This issue has been resolved in version 9.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants