Tag Archives: salt

jinja create file from template without empty lines

Issue

Creation of file from pillar simple list with Jinja template will be create empty line, in top or bottom of file, dependence for template syntax.
You can not create file without empty lines.

#!/usr/bin/python
from jinja2 import Template

d = {'testlist':['item1','item2','item3']}

tmpl = '''{%- for item in testlist %}
   {{ item }}
{%- endfor %}'''

t = Template(tmpl)
print( t.render( d ) )

Continue reading