-
Notifications
You must be signed in to change notification settings - Fork 170
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
Variable function evaluator #572
Variable function evaluator #572
Conversation
Note; this is my first PR for this project; firstly thank for maintaining it, secondly if you want any improvements to be made in order to get this merged, please let me know and I'll see what I can do. |
PPS. Should also say I added a Maven wrapper as well; simply invoke mvnw instead of mvn if you don't alreaedy have the correct version of Maven installed. |
d7b83aa
to
817c409
Compare
817c409
to
730a769
Compare
Hi - any thoughts of what would need to be changed to get this merged? Thanks :) |
+1 - This would be a really useful enhancement. I have an exact use case for this dynamic processing of the variable names. |
+1 - for this PR...I have a use case with this PR in that I'd like to override the default value for a variable when It's not found...so hopefully it can be merged soon 🙏 |
This is a useful feature to resolve many template variables supplied from multiple sources |
+1 for this PR, for complex templates and costly variables (say we need to call APIs to have values) it's super useful to know at template resolution time which ones are needed and which ones are not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this, it is a very nice option
Thank you for merging it, and your continued work on the project! |
This PR adds the ability to supply a "Variable Function" - a
java.util.Function<String, Object>
that will map a variable name to it's value.This is useful when you do not know the variables that may exist in a template at run time. Rather than populate the
Map<String, Object>
with every possible variable that can be supported, simply set the variable function that will be called at runtime. The code in yourFunction
can then determine the value when it is needed.Note that this is slightly different to the LazyExpression concept that already exists - this is a
Supplier
, so requires the caller to know the list of variables to populate in advance.