You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Django template It's tricky to access specific array element by index if array is obtained as the result of applying a filter, because it's impossible to directly use index after filter.
I.e. I want only third part of the path
data = /first/second/third/fourth
data|split:'/'|slice:'2:3'|join:''
not very clear and intuitive, slice with single element still returns an array.
Better with custom JS filter, but not very portable, you need to supply your custom filter with your template:
In[Param];
data|split:'/'|index:'2'
In Jinja2 element can be easily accessed by index or slice can be taken without additional filters:
In Django template It's tricky to access specific array element by index if array is obtained as the result of applying a filter, because it's impossible to directly use index after filter.
I.e. I want only
third
part of the pathnot very clear and intuitive,
slice
with single element still returns an array.Better with custom JS filter, but not very portable, you need to supply your custom filter with your template:
In Jinja2 element can be easily accessed by index or slice can be taken without additional filters:
Go template has an
index
function.The text was updated successfully, but these errors were encountered: