-
Notifications
You must be signed in to change notification settings - Fork 0
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
Specifying target context doesn't work unless format also specified #1
Comments
Hi Ross. This sounds like a case I hadn't accounted for. Could you provide some extra input so I can have this fixed? One of the features I have added is dictionary squashing. I.e. you can provide multiple json (dict-like) files, which will be squashed into a single dictionary to be used during rendering. E.g. if you supply two files containing This works fine as long as all json input is dict-like. But what would be the expected behaviour if json input was:
Of course, a PRs would also be welcome if you have already worked something out. |
So the GitLab JSON I'm using looks like this:
My straw-man proposal would be to probe the parsed JSON and if the top-level object is a |
I believe I have already added support for this case, but I haven't updated the docs:
I.e.:
Would this work for you? |
Oh, that looks promising. I'll try it shortly. |
So my own jinja CLI does this:
But using
I'll be able to dig further later. |
Are you sure you're using my fork of j2? This feature shouldn't be available in kolypto's version. Btw, I will probably be spinning-off my fork as a new pypi package. I have a fair amount of new features plus some more coming, that spinning off starts to make more sense than attempting to sync with the upstream. |
Yes, this is definitely your fork. |
Ok. Will take a look later in the day.
|
In the meantime, can you check different settings for the -U option? IIRC, the upstream has a different and non-configurable default.
|
I threw in a bit more
It didn't slurp up the entire list, but just put the first element of the array in the dictionary as |
Omitting the format of the input file in spec doesn't seem to work as expected. Explicitly specifying the format seems to work though:
I'll add to my todo list to make the input spec parsing more robust. |
Confirmed that adding the format fixes the problem, thanks. |
First, thanks for forking j2cli. I filed an issue with the upstream repo but that is dead now so I thought I'd file it here :)
A lot of the times that I could use j2cli the input JSON isn't a dictionary but is a plain array, for example the output from GitLab's pipeline API is an array of dictionaries.
Currently, this causes j2cli to error out. Maybe j2cli could detect that the top-level object is a list not a dict and pass it as a named variable (
data
?) in the environment?The text was updated successfully, but these errors were encountered: