Project

General

Profile

Bug #32461

save_to_file() in templates cuts off last end of line

Added by Don H 9 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Category:
Templates
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:

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.

Associated revisions

Revision 638c4be8 (diff)
Added by Lukas Zapletal 2 months ago

Fixes #32461 - add endline in save_to_file

Co-authored-by: Ondřej Ezr <>

History

#1 Updated by The Foreman Bot 9 months ago

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

#2 Updated by The Foreman Bot 2 months ago

  • Fixed in Releases 3.2.0 added

#3 Updated by Lukas Zapletal 2 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by The Foreman Bot about 2 months ago

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

#5 Updated by The Foreman Bot about 2 months ago

  • Fixed in Releases 3.1.1 added

#6 Updated by Amit Upadhye about 2 months ago

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

#7 Updated by Amit Upadhye about 2 months ago

  • Category set to Templates

Also available in: Atom PDF