allow trailing newline in Jinja2 #1388

merged 1 commit into from Apr 7, 2016


None yet

4 participants


Jinja2 by default will trim a single trailing newline.

Most time we will need this trailing newline IMHO :)


Can you clarify when that kwarg was added to Jinja? tl;dr if this is going to change behavior unexpectedly for folks, I'd rather punt on it for now :) thanks!


Ah, how could I never think this change will break someone else.
I've changed the code, adding a 'keep_trailing_newline' kwargs, because it's False default to Jinja2 env.


I too have this problem. Files in /etc/cron.d must end in a newline (for some stupid reason), otherwise they do not take effect. My templates have that explicit newline, which is stripped out on deployment. So basically, deploying disables all application crons. Not ideal. :)


@datashaman Hah, gross. thanks for the useful feedback! (Not sarcasm.) Tossing this into a release bucket since it's small & decently sized impact for some use cases.

@bitprophet bitprophet added this to the 1.10.3 milestone Jan 5, 2016

I just ran into this issue today, with cron.. merge timeframe?? Came up with a hack, but still i rather not..

run('printf "\n" >> /tmp/user.crt') # run this after (in my case fabric upload_template)


If you're stuck with this issue ATM, it's easy enough to add another step
in your fabfile in the meantime:

sudo('echo "" >> /etc/cron.d/myfile')

On 26 January 2016 at 01:51, buzzijavier wrote:

I just ran into this issue today, with cron.. merge timeframe??

Reply to this email directly or view it on GitHub
#1388 (comment).

@bitprophet bitprophet modified the milestone: 1.11, 1.10.3 Apr 7, 2016
@bitprophet bitprophet merged commit 445598a into fabric:master Apr 7, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
@bitprophet bitprophet added a commit that referenced this pull request Apr 7, 2016
@bitprophet bitprophet Doc+changelog updates re #1388 f721f01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment