Use strip_heredoc where possible

Following up on an observation by @rafaelfranca

https://github.com/rails/rails/pull/10170/files#r3753963

Reduce the number of gsub calls to the two cases where inputs are concatenated
from various sources and with inconsistent indentation.

Also zap extraneous spacing from the sass-rails line... presumably this is a
holdover from a previous time where this aligned the version string with an
adjacent line.
Merge pull request #10178 from rubys/app_base_strip_heredoc

Use strip_heredoc where possible