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

Is there a support / planned support for async filters? #232

Closed
kyrisu opened this issue Jun 22, 2020 · 3 comments
Closed

Is there a support / planned support for async filters? #232

kyrisu opened this issue Jun 22, 2020 · 3 comments

Comments

@kyrisu
Copy link

kyrisu commented Jun 22, 2020

I'm trying to refactor my code that is currently using liquid module to use liquidjs and one thing I'm missing are async filters. Something that would allow me to do:

{{ userId | get_user_data | json }}

where get_user_data is an async function calling external API.

Is something like this currently possible? Any workaround that could make this possible?

I've looked through the docs and tickets and the only thing I've found is the async context resolution.

@harttle
Copy link
Owner

harttle commented Jun 25, 2020

Filters cannot be async currently, but we do support async drops, see this test case:

https://github.com/harttle/liquidjs/blob/master/test/integration/drop/drop.ts#L48

@harttle
Copy link
Owner

harttle commented Jun 25, 2020

Async filters are now supported, see this test case:

liquid.registerFilter('get_user_data', function (userId) {
return Promise.resolve({ userId, userName: userId.toUpperCase() })
})
it('should support async filter', async () => {
const src = `{{ userId | get_user_data | json }}`
const dst = '{"userId":"alice","userName":"ALICE"}'
const html = await liquid.parseAndRender(src, { userId: 'alice' })
return expect(html).to.equal(dst)
})

harttle pushed a commit that referenced this issue Jun 25, 2020
# [9.13.0](v9.12.0...v9.13.0) (2020-06-25)

### Features

* async filters, closes [#232](#232) ([e36f3ff](e36f3ff))
@harttle
Copy link
Owner

harttle commented Jun 25, 2020

🎉 This issue has been resolved in version 9.13.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