Closed BenAlanSouthall closed 1 year ago
👀
Very interesting and good reproduction steps. Lemme see if I can reproduce myself and if I can see anything obviously wrong.
This worked just fine for me locally?
[main][jinja2-cli/samples]$ cat sample.json | jq -c | tee sample.oneLine.json | jinja2 --format=json sample.jinja2
<html>
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</html>
[main][jinja2-cli/samples]$ cat sample.oneLine.json
{"items":["foo","bar","baz"]}
[main][jinja2-cli/samples]$ cat sample.json
{
"items": [
"foo",
"bar",
"baz"
]
}
[main][jinja2-cli/samples]$ cat sample.jinja2
<html>
{% if foo is defined -%}
<!-- foo was defined -->
{% endif -%}
{% if bar is defined -%}
<h1>Hey it's there!</h1>
{% endif -%}
<ul>
{% for item in items -%}
<li>{{ item }}</li>
{% endfor -%}
</ul>
</html>
It's certainly strange. Could it be dependent packages that PIP hasn't bumped when installing the CLI? I.e. we are on different versions of some dependency. Or even due to different python versions.
In either case, I moved over to j2
instead and only need this for something small, so am happy if you want to close for now, and if it crops up again in the wild someone else can re-open
Yeah, not entirely sure, this was manually tested against python 3.10, and just installed from main. I've not heard of any issues like this before, since the formatting shouldn't matter at all.
Oh well, sorry it didn't work out for you.
MRPE:
IUsing the samples given, it seems placing all the iunput on one line messes with the input parsing, even when I try to force it. Variables are not defined, if I use the
--strict
flag.