google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.92k stars 438 forks source link

documentation for importstr #1068

Closed kintarowins closed 1 year ago

kintarowins commented 1 year ago

I'm looking for a way to read from an external file and it seems everyone is talking about importstr but for the life of me, I cannot find any documentation for it anywhere from the official jsonnet.org website. There's mention of the function, but nothing in the References, Tutotorial or Standard Library pages.

sparkprime commented 1 year ago

importstr is just like import but returns a string instead of a Jsonnet value.

There should be more in the tutorial and reference about this, but in the spec it says:

The semantics of these constructs is that they are replaced with either the contents of the file, or an error construct if importing failed (e.g. due to I/O errors). In the first case, the file is parsed, desugared, and subject to static checking before it can be substituted. In the case of importstr, the file is substituted in the form of a string, so it merely needs to contain valid UTF-8. For importbin, the file is substituted as an array of integer numbers between 0 and 255 inclusive.