Project Variable slicing

names is a project variable defined as:
names: [‘1’,‘2’,‘3’,‘4’]

For some cases I only want to set the variable to the previous two elements to loop through.
(Index will not work because it relates to source names and it would not compile)

Just wondering if
({% set name = var(‘names’)[0] %}) "
works,
why
{% set name = var(‘names’)[0:1] %}
won’t work.

Doesn’t it work like a normal list?
Do I have to hard code the elements?

NVM I solved it. If I want the first two items then {% set name = var(‘names’)[0:2] %}.
Just leaving it here just in case someone want to know too.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.