ede
ede copied to clipboard
Nested variable as argument to filter is reversed
Example:
{{ field.value.name | justifyRight(field.value.indent) }} :: {{ field.value.type }}
Error:
error: variable indent.value.field doesn't exist.
Is that still an issue? I cannot reproduce it... JSON context used:
{"field": {"value": {"name": "FieldName", "indent": 20, "type": "FieldType"}}}
I also have a problem with variables in filter arguments, which seems different but perhaps is related.
Take this template, where match
is a filter that matches the input to a regex and returns an object with a boolean field ok
if the match worked, and a series of fields b0
, b1
, ... for each capturing group.
Also, ifelse
is a function that returns the first argument if the input is true, the second otherwise:
{% let X = description | match(", (.+) ([0-9]+\\.[0-9]+) per CHF ([0-9]+\\.[0-9]+)") %}
{% let Y = { "ok": true, "g0": "ciao" } %}
category {% if X.ok %} {{X.g0}} {% else %} {{currency}} {% endif %}
{{ X | show }}
{{ Y | show }}
{{ Y.ok | ifelse(Y.g0, 1) }}
{% endlet %}
{% endlet %}
Both show
print an object with ok
and g0
, and everything works.
However, if I replace ifelse(X.g0, 1)
for ifelse(Y.g0, 1)
I get the error
variable X.g0 doesn't exist