Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't (easily) index a literal array #933

Open
ChrisJefferson opened this issue Aug 19, 2024 · 2 comments
Open

Can't (easily) index a literal array #933

ChrisJefferson opened this issue Aug 19, 2024 · 2 comments

Comments

@ChrisJefferson
Copy link

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.

@ChrisJefferson
Copy link
Author

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.

@Keats
Copy link
Owner

Keats commented Aug 21, 2024

I've added support for it in the next version: Keats/tera2#42
Nice catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants