tera
tera copied to clipboard
Can't (easily) index a literal array
I was trying to index a literal array, to get a label, for example:
['up', 'down', 'left', 'right'][1]
But this doesn't work, I get:
expected a filter or a variable end
Now, I can fix this by writing:
['up', 'down', 'left', 'right'] | nth(n=1)
But it took me a while to find that, and I expected the 'obvious thing' to work.
I also found I can write {% x = ['up', 'down', 'left', 'right'] %}, then use {{ x[1] }}, so it's not too hard to work around, but the error message did confuse me for a while.
I've added support for it in the next version: https://github.com/Keats/tera2/pull/42 Nice catch!