Skip to content

Commit

Permalink
Replace linebreaks in lines consisting only of arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthes committed Nov 2, 2017
1 parent aba79cd commit ecd2f3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/TextTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,14 @@ private function _removeComments ($input) {


private function _removeWhitespace ($input) {
//echo $input;
$input = preg_replace("/\}\s*\{(?!=)/im", "}{", $input);
//echo $input;
// Replace: All lines
// - Starting with Newline and optional spaces
// - With only {xyz}
// - Not Starting with {=
// And ending with newline by single line
//
// Caution: Lookahead at the end required to strip multiple lines!
$input = preg_replace("/\\n\s*(\{(?!\=)[^\}]+?\})(?=[\\n\{])/m", '$1', $input);
return $input;
}

Expand Down
1 change: 1 addition & 0 deletions test/unit/tpls/06_debug_vars/out.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1: Start

----- __CONTEXT__ -----
array (
'boolVal' => true,
Expand Down

0 comments on commit ecd2f3a

Please sign in to comment.