I have some variables in a jinja2 template which are strings seperated by a ';'.
I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue"
{% list1 = {{ variable1 }}.split(';') %}
The grass is {{ list1[0] }} and the boat is {{ list1[1] }}
I can split them up before rendering the template but since it are sometimes up to 10 strings inside the string this gets messy.
I had a jsp before where I did:
<% String[] list1 = val.get("variable1").split(";");%>
The grass is <%= list1[0] %> and the boat is <%= list1[1] %>
EDIT:
It works with:
{% set list1 = variable1.split(';') %}
The grass is {{ list1[0] }} and the boat is {{ list1[1] }}