default(x, value)
only works properly with names and exists("x")
and existsIn(y, "x")
only works properly with strings
#203
Labels
Inja has three constructs which query names that may possibly not exists.
default
, which takes the name as a name, e.g.default(x)
notdefault("x")
. If a string is provided instead of a name, the string is returned without an error.exists
andexistsIn
, which take the name as a string, e.g.exists("x")
notexists(x)
. If a name is provided instead of a string, these functions work if the name exists, and a render error occurs if the name does not exist.Check it out on Godbolt here.
This dichotomy is a bit unintuitive. It's also restrictive - you might want to dynamically construct or look up a name as a string and then pass it to
default
, but you cannot do that today.I think all of these functions should accept either names or strings and do the right thing with them. That would mean extending
exists
andexistsIn
to take strings, and changing the behavior ofdefault
when a string is passed in.The text was updated successfully, but these errors were encountered: