-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add Support for IEnumerable tokens on TextTransformationExtensions #2124
Conversation
Updated as requested in feedback. |
@maldworth quick question... Is there an open issue associated with this pull request? |
@gep13 No open issue. I just thought this would be helpful to have this option @patriksvensson I believe I made the changes as requested. Can you take another look when you have a chance? thank you |
@gep13 I recently added a similar request in #2375 before discovering this PR just now. @maldworth @patriksvensson can we sort out the final details and merge this in time for Cake 0.31? Before that however, I do have a couple of suggestions for my own requirements. As per the sample code in my issue, this extension method would be much more convenient and useful if:
Re the second point, from experience I've found it much cleaner and safer to leave token placeholders behind for tokens without a value. This is especially helpful if staging a template after rendering, before publishing as an artifact, as it helps to diagnose issues at build-time. Also, it would be nice if we could include my |
@gitfool if it was silent to missing tokens or null params, then perhaps it would be a .TryWithTokens(). Or perhaps add a parameter to ignore missing tokens? anyways it would be nice to see this merged in sooner rather than later. Or we can combine both into one PR. Doesn't matter to me. |
@maldworth your suggested behavior is problematic as TextTransformationTemplate.Replace already silently replaces tokens without a value, technically with a I suppose the other option would be to throw an exception if a token value is |
af1eb89
to
cb27b5a
Compare
This have been merged. Sorry for the delay... |
As a result of this PR #2509 the overall aim of this PR has changed a little bit, so I have updated the title of this one (which will be included in the release notes) to reflect the final outcome. |
I would like to add the ability for adding a dictionary of tokens.
I have a JSON file of key values, and when I use newtonsoft to deserialize, it defaults into an IDictionary<string,object>, and so I'd like to simply pass that into the TextTransform Extension Method.