I\'m using jinja 2 to output a yaml file but can\'t seem to get rid of a trailing newline and the end of a for loop. Eg the below
- request:
path: {{ p
You can suppress rendering of the below lines:
<% for ... %>
<% endfor %>
<% if ... %>
<% endif %>
by setting trim_blocks=True and lstrip_blocks=True in your jinja2 environment. See the example below, info from their docs
context = {'querystring': querystring, 'path': path, 'content': content}
jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates/'), trim_blocks=True, lstrip_blocks=True)
print(jinja_env.get_template('my_template.yaml').render(context))