jsonnet
jsonnet copied to clipboard
Add ability to refer to subfields of objects via dot notation in string formatting
You can now do something like this:
"%(a.b)s" % {a:{b:"hello world"}} which yields "hello world"
This is similar to python3's format strings behavior, though much simpler in capability. Every subfield must be an object except the last one.
Tested: added new happy path format test, and an error test
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
@sparkprime Hi, wanted to check what you thought of this PR.
I only just noticed this. It seems like it could be useful for a fair few cases but it's a bit too big for the release I'm just doing.
At this point I've used a workaround like "%(b)s" % {b: a.b} but I'm still happy to submit this if you think it's a usability improvement.