'Format output of Jinja2 template

Quite new to jinja2 templating and my target is to get as output of the rendering the following (which is not the case now)

port = [22, 25, 80, 143,3306,5666]

I am not using salt or ansible so I can not use already created jinja2 filter. Data is a json file, template a jinja2. Result of rendering is for now written in a txt file and result is

"port": "22",  
"port": "25",  
"port": "80",  
"port": "143",  
"port": "3306",  
"port": "5666",  

Is there any way (filter) that i can use in my template to get the target output? At the end I would like to use the created array as input for a different function. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source