Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
7ed746ad
Commit
7ed746ad
authored
Sep 02, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix preserve_trailing_newlines (broken by
7f5080f6
)
Fix for one half of hte bug reported in #12198
parent
a7231c22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletions
+12
-1
lib/ansible/template/__init__.py
+12
-1
No files found.
lib/ansible/template/__init__.py
View file @
7ed746ad
...
...
@@ -316,6 +316,10 @@ class Templar:
def
_do_template
(
self
,
data
,
preserve_trailing_newlines
=
False
,
fail_on_undefined
=
None
,
overrides
=
None
):
# For preserving the number of input newlines in the output (used
# later in this method)
data_newlines
=
self
.
_count_newlines_from_end
(
data
)
if
fail_on_undefined
is
None
:
fail_on_undefined
=
self
.
_fail_on_undefined_errors
...
...
@@ -377,8 +381,15 @@ class Templar:
# characters at the end of the input data, so we use the
# calculate the difference in newlines and append them
# to the resulting output for parity
#
# jinja2 added a keep_trailing_newline option in 2.7 when
# creating an Environment. That would let us make this code
# better (remove a single newline if
# preserve_trailing_newlines is False). Once we can depend on
# that version being present, modify our code to set that when
# initializing self.environment and remove a single trailing
# newline here if preserve_newlines is False.
res_newlines
=
self
.
_count_newlines_from_end
(
res
)
data_newlines
=
self
.
_count_newlines_from_end
(
data
)
if
data_newlines
>
res_newlines
:
res
+=
'
\n
'
*
(
data_newlines
-
res_newlines
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment