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

Support function calls #222

Closed
romaricpascal opened this issue Apr 23, 2020 · 4 comments
Closed

Support function calls #222

romaricpascal opened this issue Apr 23, 2020 · 4 comments

Comments

@romaricpascal
Copy link

Hello,

I was wondering if there was plan for supporting function calls inside the templates.

  • rendering the value {{obj.property()}} breaks with unexpected token at "()". Can be worked around with an apply filter {{obj.property | apply}} but it's not really straightforward
  • assign breaks with the same error
  • if , for and case don't break but seem to ignore the returned value

That would be ideal to avoid too much gymnastics (and I guess allow what's already possible in Ruby, as function calls don't necessarily need parenthesis, or does Liquid break that behaviour?)

Cheers :)

@harttle
Copy link
Owner

harttle commented Apr 24, 2020

Sounds reasonable. I prefer the {{obj.property}} approach, in which we should check if it's a function before reading its value.

@romaricpascal
Copy link
Author

Do you mean check if the property is a function and invoke it automatically? I like that! Wouldn't that leave out all the functions that need parameters out though?

@harttle
Copy link
Owner

harttle commented Apr 24, 2020

I'm not sure if that's the behavior for shopify/liquid, but we definitely should align to that behavior whenever possible. I'll dig into it later, and any kind of PR is welcome.

harttle pushed a commit that referenced this issue Feb 12, 2021
# [9.23.0](v9.22.1...v9.23.0) (2021-02-12)

### Bug Fixes

* respect `fs` in parser options, for [#233](#233) ([4e82da6](4e82da6))

### Features

* support filters in if/unless/case, see [#287](#287) ([2f059f6](2f059f6))
* support function calls, closes [#222](#222) ([e37824f](e37824f))
* support layout none, closes [#299](#299) ([81e11bb](81e11bb))
@harttle
Copy link
Owner

harttle commented Feb 12, 2021

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