Preserve trailing newline after templating.
Jinja seems to eat trailing whitespace. A lot of tools complain about this: iptables-restore, iscsid...
This commit is contained in:
parent
1dbea82350
commit
55fbc95243
1 changed files with 4 additions and 1 deletions
|
@ -241,7 +241,10 @@ def template(text, vars, setup_cache, no_engine=False):
|
||||||
return text
|
return text
|
||||||
else:
|
else:
|
||||||
template = jinja2.Template(text)
|
template = jinja2.Template(text)
|
||||||
return template.render(vars)
|
res = template.render(vars)
|
||||||
|
if text.endswith('\n') and not res.endswith('\n'):
|
||||||
|
res = res + '\n'
|
||||||
|
return res
|
||||||
|
|
||||||
def double_template(text, vars, setup_cache):
|
def double_template(text, vars, setup_cache):
|
||||||
return template(template(text, vars, setup_cache), vars, setup_cache)
|
return template(template(text, vars, setup_cache), vars, setup_cache)
|
||||||
|
|
Loading…
Add table
Reference in a new issue