Closed ogdenwebb closed 5 years ago
Hi there @ogdenwebb! So javascript can get away with this because:
var a = [1,2,3];
a[0] // 1
a["0"] // 1
i.e. an array is just an object (sort of ;) ).
This is not the case in Nim:
var a = @[0,1,2]
a["0"] # breaks
a[0]
In any case, since the official spec doesn't support it, it is not something moustachu will support. Typically, you would store the array element you want to access individually in a separate key. Then you would call it via its key, like any other element.
Thanks for the answer.
Typically, you would store the array element you want to access individually in a separate key.
My JSON file has enough array data, which I would have access, so that isn't best solution for me in this case.
In any case, since the official spec doesn't support it, it is not something moustachu will support.
Well, close then.
Some implementations(at least js) of Mustache allow to access array value by index, like that.
Is there a way to achieve it with moustachu.nim? If no, would you add this?