lib/generator.rb: Ignore blank template lines.#479
Conversation
If you have a template that contains a value that might be nil or an empty string such as: ``` <%= test_case.comment %> ``` You often do not want a blank line appear in the output if there is no comment. This patch changes the ERB setttings so that these blank lines are not included in the output. This may cause minor issues where this behaviour has been relied on such as templates that expect a Ruby syntax related 'end' to insert a blank line. ``` <% end %> ``` But these are easily fixed by inserting a new blank line into the template. Technical details: It does this by setting the ERB *trim_mode* to '<>' '<>' omits newline for lines starting with <% and ending in %> See also: http://ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html#method-c-new
|
This will require most The tweak will be to add a new blank line after: |
|
I considered the same issues when I did Hamming, addressing the |
"Very", I think. Every problem will need skipped or not skipped and this is a more elegant way to handle that. As well as cases with optional comments which will be possible to do now.
Yes it does, but for the better, and the implications for any that do not need this functionality are extremely minor. becomes (1 extra newline character) |
If you have a template that contains a value that might be nil or an empty string such as:
You often do not want a blank line appear in the output if there is no comment.
This patch changes the ERB setttings so that these blank lines are not included in the output.
This may cause minor issues where this behaviour has been relied on such as templates that expect a Ruby syntax related 'end' to insert a blank line.
But these are easily fixed by inserting a new blank line into the template.
Technical details:
It does this by setting the ERB trim_mode to '<>'
'<>' omits newline for lines starting with <% and ending in %>
See also: http://ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html#method-c-new