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

where as a function? #73

Open
imacks opened this issue Sep 26, 2018 · 3 comments
Open

where as a function? #73

imacks opened this issue Sep 26, 2018 · 3 comments

Comments

@imacks
Copy link

imacks commented Sep 26, 2018

this is a great templating engine! is it possible to pass a condition to a custom function? i want to implement a where type of filtering functionality:

  • where:
[1,3,5] | where ($_ <4)
[1,3]
@imacks imacks changed the title for as a function? where as a function? Sep 26, 2018
@xoofx
Copy link
Member

xoofx commented Oct 29, 2018

This is not currently possible. It would require to implement this feature, similar to the way we implement the operator @ when you want to pass a function pointer

@lafar6502
Copy link
Contributor

@xoofx can you give some examples of how what is supported with '@' operator? Or anonymous functions - is this supported? If so, what is the use case?

@xoofx
Copy link
Member

xoofx commented Dec 28, 2018

can you give some examples of how what is supported with '@' operator?

There is a bit of doc in https://github.com/lunet-io/scriban/blob/master/doc/language.md#7-functions

By default, when you are using a variable, it is going to call it if it is a function. Using the @ prefix allows to store a reference to the function itself

Or anonymous functions - is this supported? If so, what is the use case?

Anonymous functions are currently not supported. The closest builtin is the wrap statement

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

3 participants