save_to_file() in templates cuts off last end of line
I have noticed when I have two save_to_file() calls right after each other that save_to_file is cutting off the last end of line.
<%= save_to_file('/tmp/first_file', snippet('first_template')) %> <%= save_to_file('/tmp/second_file', snippet('second_template')) %>
If there is not an extra empty line in the snippet passed to save_to_file, then you get something generated like this:
cat << EOF > /tmp/first_file This is my first file This is the last lineEOF
And if you have two calls to save_to_file right after each other, they will get put into the same file, because the EOF from the first file is not on a line by itself and you get something like this.
cat << EOF > /tmp/first_file This is my first file This is the last lineEOF cat << EOF > /tmp/second_file This is my second file This is the last lineEOF
And the CONTENT of the generate file contains something like this due to the end of line being cutoff.
This is my first file This is the last lineEOF cat << EOF > /tmp/second_file This is my second file This is the last line
There is probably an extra trim or something being done to the snippet data being sent to save_to_file.
If I add an extra blank line onto all the snippets used with save_to_file then the EOF is alone on the last line as required.