-
Notifications
You must be signed in to change notification settings - Fork 228
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 string.format #617
Add string.format #617
Conversation
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.
Not a full review pass, but noticed a few things.
@DangerOnTheRanger Please move this functionality to |
@DangerOnTheRanger I have some questions based on what I've seen. Can you tell me the intended behavior for the following calls: // error based on list literal size or simply a reuse of the first argument in the string?
"{0} < {0}".format([1, 2])
// How are brackets escaped?
"{{0}: {1}}".format([key, value]) It sounds like you and Joe have adequately answered whether the digits are Ascii-only, and I'm fine with that as well. |
For the first one, as currently written the implementation would accept this (the first argument would be reused) but after offline discussion with @jpbetz I think this should result in a compile-time error if the formatting string is a constant. For the second, that would result in an error ( |
/gcbrun LGTM |
943601b
to
20e868d
Compare
(force push to fix merge conflict) |
20e868d
to
83a4e49
Compare
/gcbrun |
8d6ff33
to
6d8b253
Compare
/gcbrun |
6d8b253
to
7a6f7ff
Compare
/gcbrun |
@jpbetz Would you mind checking if the request changes addressed? Looks like the change request is blocking the merging process on this one. Thank you :) |
This PR adds a
format
receiver function to CEL strings. The syntax is similar to theprintf
implementations found in various languages. For example,"%s and a number: %d".format(["a string", 42])
evaluates to"a string and a number: 42"
.