forked from a-h/templ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fmt): Preserve newlines in most parsers (a-h#374)
- Loading branch information
1 parent
dc3c684
commit aa31f93
Showing
25 changed files
with
397 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
parser/v2/formattestdata/calltemplate_newline_is_preserved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- in -- | ||
package main | ||
|
||
templ test() { | ||
<span></span> | ||
|
||
|
||
{! Other(p.Test) } | ||
{!Other(p.Test)} Home | ||
|
||
<div>Some standard templ</div> | ||
|
||
{!Other(p.Test) } | ||
|
||
|
||
|
||
<span></span> | ||
|
||
} | ||
-- out -- | ||
package main | ||
|
||
templ test() { | ||
<span></span> | ||
|
||
@Other(p.Test) | ||
@Other(p.Test) Home | ||
<div>Some standard templ</div> | ||
|
||
@Other(p.Test) | ||
|
||
<span></span> | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
parser/v2/formattestdata/comments_newline_is_preserved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- in -- | ||
package main | ||
|
||
templ test() { | ||
<!-- This is a comment --> | ||
|
||
// This is not included in the output. | ||
<div>Some standard templ</div> | ||
|
||
|
||
/* This is not included in the output too. */ | ||
/* | ||
Leave this alone. | ||
*/ | ||
|
||
|
||
} | ||
-- out -- | ||
package main | ||
|
||
templ test() { | ||
<!-- This is a comment --> | ||
|
||
// This is not included in the output. | ||
<div>Some standard templ</div> | ||
|
||
/* This is not included in the output too. */ | ||
/* | ||
Leave this alone. | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
parser/v2/formattestdata/for_loops_newline_is_preserved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- in -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
for _, item := range items { | ||
|
||
<div>{ item }</div> | ||
|
||
} | ||
|
||
|
||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} | ||
-- out -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
for _, item := range items { | ||
<div>{ item }</div> | ||
|
||
} | ||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} |
37 changes: 37 additions & 0 deletions
37
parser/v2/formattestdata/if_statement_newline_is_preserved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- in -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
if true { | ||
<span>Test</span> | ||
|
||
} else { | ||
|
||
<span>Test</span> | ||
} | ||
|
||
|
||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} | ||
-- out -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
if true { | ||
<span>Test</span> | ||
|
||
} else { | ||
<span>Test</span> | ||
} | ||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- in -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
switch items[0] { | ||
|
||
|
||
case "a": | ||
<div>{ items[0] }</div> | ||
|
||
|
||
case "b": | ||
<div>{ items[1] }</div> | ||
|
||
} | ||
|
||
|
||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} | ||
-- out -- | ||
package main | ||
|
||
templ x() { | ||
<div> | ||
<span></span> | ||
|
||
switch items[0] { | ||
case "a": | ||
<div>{ items[0] }</div> | ||
|
||
case "b": | ||
<div>{ items[1] }</div> | ||
|
||
} | ||
|
||
<span>Foo Bar </span> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.