Project

General

Profile

Actions

Bug #32461

closed

save_to_file() in templates cuts off last end of line

Added by Don H over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Templates
Target version:
-
Fixed in Releases:
Found in Releases:

Description

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.

Example:

<%= 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.

Actions #1

Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Lukas Zapletal
  • Pull request https://github.com/theforeman/foreman/pull/8488 added
Actions #2

Updated by The Foreman Bot about 3 years ago

  • Fixed in Releases 3.2.0 added
Actions #3

Updated by Lukas Zapletal about 3 years ago

  • Status changed from Ready For Testing to Closed
Actions #4

Updated by The Foreman Bot almost 3 years ago

  • Pull request https://github.com/theforeman/foreman/pull/8976 added
Actions #5

Updated by The Foreman Bot almost 3 years ago

  • Fixed in Releases 3.1.1 added
Actions #6

Updated by Amit Upadhye almost 3 years ago

  • Fixed in Releases 3.1.0 added
  • Fixed in Releases deleted (3.1.1, 3.2.0)
Actions #7

Updated by Amit Upadhye almost 3 years ago

  • Category set to Templates
Actions

Also available in: Atom PDF