Templates don't like top-level lists
Closed this issue · 5 comments
marwatk commented
Command-level getv works fine with a top-level list:
$ clconf --pipe getv /0 <<'EOF'
[{"key": "value"}]
EOF
key: value
But a template is not:
$ clconf --pipe getv / --template-string '{{ getv "/0" }}' <<'EOF'
[{"key": "value"}]
EOF
Error: template execute: execute template: template: cli:1:3: executing "cli" at <getv "/0">: error calling getv: /0: key does not exist
marwatk commented
It's more than just lists, which makes me thing I'm doing something fundamentally wrong:
$ clconf --pipe getv / --template-string '{{ get "/foo" }}' <<EOF
foo:
key: val
EOF
Error: template execute: execute template: template: cli:1:3: executing "cli" at <get "/foo">: error calling get: /foo: key does not exist
marwatk commented
It's just any root element:
Root:
$ clconf --pipe getv / --template-string '{{ getv "/foo" }}' <<EOF
foo:
key: val
EOF
Error: template execute: execute template: template: cli:1:3: executing "cli" at <getv "/foo">: error calling getv: /foo: key does not exist
Non-root:
$ clconf --pipe getv / --template-string '{{ getv "/foo/key" }}' <<EOF
foo:
key: val
EOF
val
marwatk commented
But it's very specifically only roots that have subkeys:
$ clconf --pipe getv / --template-string '{{ getv "/key" }}' <<EOF
key: val
EOF
val
marwatk commented
This is because the template is operating on a key-value store, and has no concept of keys that don't have direct values. We kinda call this out in the docs, but the implications are definitely not obvious.