+}
diff --git a/parser/v2/testdata/comments_are_preserved.txt b/parser/v2/testdata/comments_are_preserved.txt
new file mode 100644
index 000000000..0da95634f
--- /dev/null
+++ b/parser/v2/testdata/comments_are_preserved.txt
@@ -0,0 +1,24 @@
+-- in --
+package main
+
+templ test() {
+
+ // This is not included in the output.
+
Some standard templ
+ /* This is not included in the output too. */
+ /*
+ Leave this alone.
+ */
+}
+-- out --
+package main
+
+templ test() {
+
+ // This is not included in the output.
+
Some standard templ
+ /* This is not included in the output too. */
+ /*
+ Leave this alone.
+ */
+}
diff --git a/parser/v2/testdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt b/parser/v2/testdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt
new file mode 100644
index 000000000..195558cfc
--- /dev/null
+++ b/parser/v2/testdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt
@@ -0,0 +1,24 @@
+-- in --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
+Content
+}
+-- out --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
+ Content
+
+}
diff --git a/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented.txt b/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented.txt
new file mode 100644
index 000000000..a29d2037f
--- /dev/null
+++ b/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented.txt
@@ -0,0 +1,21 @@
+-- in --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
+-- out --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
diff --git a/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented__2.txt b/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented__2.txt
new file mode 100644
index 000000000..4f60cc526
--- /dev/null
+++ b/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented__2.txt
@@ -0,0 +1,22 @@
+-- in --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
+-- out --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
diff --git a/parser/v2/testdata/conditional_expressions_with_else_blocks_are_also_formatted.txt b/parser/v2/testdata/conditional_expressions_with_else_blocks_are_also_formatted.txt
new file mode 100644
index 000000000..4ff95d375
--- /dev/null
+++ b/parser/v2/testdata/conditional_expressions_with_else_blocks_are_also_formatted.txt
@@ -0,0 +1,26 @@
+-- in --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
+-- out --
+package test
+
+templ conditionalAttributes(addClass bool) {
+
Content
+}
diff --git a/parser/v2/testdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt b/parser/v2/testdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt
new file mode 100644
index 000000000..5c785630a
--- /dev/null
+++ b/parser/v2/testdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt
@@ -0,0 +1,17 @@
+-- in --
+package test
+
+templ nested() {
+
double
+
single-not-required
+
single-required
+}
+
+-- out --
+package test
+
+templ nested() {
+
double
+
single-not-required
+
single-required
+}
diff --git a/parser/v2/testdata/css_is_indented_by_one_level.txt b/parser/v2/testdata/css_is_indented_by_one_level.txt
new file mode 100644
index 000000000..403e40367
--- /dev/null
+++ b/parser/v2/testdata/css_is_indented_by_one_level.txt
@@ -0,0 +1,14 @@
+-- in --
+package test
+
+css ClassName() {
+background-color: #ffffff;
+color: { constants.White };
+}
+-- out --
+package test
+
+css ClassName() {
+ background-color: #ffffff;
+ color: { constants.White };
+}
diff --git a/parser/v2/testdata/css_whitespace_is_tidied.txt b/parser/v2/testdata/css_whitespace_is_tidied.txt
new file mode 100644
index 000000000..f5217dd45
--- /dev/null
+++ b/parser/v2/testdata/css_whitespace_is_tidied.txt
@@ -0,0 +1,15 @@
+-- in --
+package test
+
+css ClassName() {
+background-color : #ffffff ;
+ color : { constants.White };
+ }
+
+-- out --
+package test
+
+css ClassName() {
+ background-color: #ffffff;
+ color: { constants.White };
+}
diff --git a/parser/v2/testdata/empty_elements_stay_on_the_same_line.txt b/parser/v2/testdata/empty_elements_stay_on_the_same_line.txt
new file mode 100644
index 000000000..f34bb2433
--- /dev/null
+++ b/parser/v2/testdata/empty_elements_stay_on_the_same_line.txt
@@ -0,0 +1,17 @@
+-- in --
+package test
+
+templ input(value, validation string) {
+
+
+
+
+}
+-- out --
+package test
+
+templ input(value, validation string) {
+
+
+
+}
diff --git a/parser/v2/testdata/for_loops_are_placed_on_a_new_line.txt b/parser/v2/testdata/for_loops_are_placed_on_a_new_line.txt
new file mode 100644
index 000000000..97f7d586f
--- /dev/null
+++ b/parser/v2/testdata/for_loops_are_placed_on_a_new_line.txt
@@ -0,0 +1,20 @@
+-- in --
+package test
+
+templ input(items []string) {
+
{ "the" }
{ "other" }
for _, item := range items {
+
{ item }
+}
+}
+-- out --
+package test
+
+templ input(items []string) {
+
+ { "the" }
+
{ "other" }
+ for _, item := range items {
+
{ item }
+ }
+
+}
diff --git a/parser/v2/testdata/formatting_does_not_alter_whitespace.txt b/parser/v2/testdata/formatting_does_not_alter_whitespace.txt
new file mode 100644
index 000000000..5db030a0e
--- /dev/null
+++ b/parser/v2/testdata/formatting_does_not_alter_whitespace.txt
@@ -0,0 +1,13 @@
+-- in --
+package test
+
+templ nested() {
+
{ "the" }
{ "other" }
+}
+
+-- out --
+package test
+
+templ nested() {
+
{ "the" }
{ "other" }
+}
diff --git a/parser/v2/testdata/go_expressions_are_formatted_by_the_go_formatter.txt b/parser/v2/testdata/go_expressions_are_formatted_by_the_go_formatter.txt
new file mode 100644
index 000000000..43e4e2812
--- /dev/null
+++ b/parser/v2/testdata/go_expressions_are_formatted_by_the_go_formatter.txt
@@ -0,0 +1,42 @@
+-- in --
+package main
+
+ type Link struct {
+Name string
+ Url string
+}
+
+var a = false;
+
+func test() {
+ log.Print("hoi")
+
+ if (a) {
+ log.Fatal("OH NO !")
+ }
+}
+
+templ x() {
+
Hello World
+}
+-- out --
+package main
+
+type Link struct {
+ Name string
+ Url string
+}
+
+var a = false
+
+func test() {
+ log.Print("hoi")
+
+ if a {
+ log.Fatal("OH NO !")
+ }
+}
+
+templ x() {
+
Hello World
+}
diff --git a/parser/v2/testdata/godoc_comments_are_preserved.txt b/parser/v2/testdata/godoc_comments_are_preserved.txt
new file mode 100644
index 000000000..c7f457a5a
--- /dev/null
+++ b/parser/v2/testdata/godoc_comments_are_preserved.txt
@@ -0,0 +1,14 @@
+-- in --
+package main
+
+// test the comment handling.
+templ test() {
+ Test
+}
+-- out --
+package main
+
+// test the comment handling.
+templ test() {
+ Test
+}
diff --git a/parser/v2/testdata/if_statements_are_placed_on_a_new_line.txt b/parser/v2/testdata/if_statements_are_placed_on_a_new_line.txt
new file mode 100644
index 000000000..77a40ba98
--- /dev/null
+++ b/parser/v2/testdata/if_statements_are_placed_on_a_new_line.txt
@@ -0,0 +1,25 @@
+-- in --
+package test
+
+templ input(items []string) {
+
{ "the" }
{ "other" }
if items != nil {
+
{ items[0] }
+ } else {
+
{ items[1] }
+ }
+
+}
+-- out --
+package test
+
+templ input(items []string) {
+
+ { "the" }
+
{ "other" }
+ if items != nil {
+
{ items[0] }
+ } else {
+
{ items[1] }
+ }
+
+}
diff --git a/parser/v2/testdata/inline_elements_are_not_placed_on_a_new_line.txt b/parser/v2/testdata/inline_elements_are_not_placed_on_a_new_line.txt
new file mode 100644
index 000000000..b28bc2fa0
--- /dev/null
+++ b/parser/v2/testdata/inline_elements_are_not_placed_on_a_new_line.txt
@@ -0,0 +1,20 @@
+-- in --
+package main
+
+templ test() {
+
+ In a flowing paragraph, you can use inline elements.
+ These inline elements can be styled
+ and are not placed on new lines.
+
+}
+-- out --
+package main
+
+templ test() {
+
+ In a flowing paragraph, you can use inline elements.
+ These inline elements can be styled
+ and are not placed on new lines.
+
+}
diff --git a/parser/v2/testdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt b/parser/v2/testdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt
new file mode 100644
index 000000000..87d566247
--- /dev/null
+++ b/parser/v2/testdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt
@@ -0,0 +1,12 @@
+-- in --
+package test
+
+templ input(value, validation string) {
+
Text
+}
+-- out --
+package test
+
+templ input(value, validation string) {
+
Text
+}
diff --git a/parser/v2/testdata/script_tags_are_not_converted_to_self_closing_elements.txt b/parser/v2/testdata/script_tags_are_not_converted_to_self_closing_elements.txt
new file mode 100644
index 000000000..9cd06031b
--- /dev/null
+++ b/parser/v2/testdata/script_tags_are_not_converted_to_self_closing_elements.txt
@@ -0,0 +1,13 @@
+-- in --
+package test
+
+templ input(value, validation string) {
+
+}
+
+-- out --
+package test
+
+templ input(value, validation string) {
+
+}
diff --git a/parser/v2/testdata/spacing_between_string_expressions_is_kept.txt b/parser/v2/testdata/spacing_between_string_expressions_is_kept.txt
new file mode 100644
index 000000000..a982c0aa7
--- /dev/null
+++ b/parser/v2/testdata/spacing_between_string_expressions_is_kept.txt
@@ -0,0 +1,12 @@
+-- in --
+package main
+
+templ x() {
+
{firstName} {lastName}
+}
+-- out --
+package main
+
+templ x() {
+
{ firstName } { lastName }
+}
diff --git a/parser/v2/testdata/spacing_between_string_expressions_is_not_magically_added.txt b/parser/v2/testdata/spacing_between_string_expressions_is_not_magically_added.txt
new file mode 100644
index 000000000..06ac7b072
--- /dev/null
+++ b/parser/v2/testdata/spacing_between_string_expressions_is_not_magically_added.txt
@@ -0,0 +1,12 @@
+-- in --
+package main
+
+templ x() {
+
{pt1}{pt2}
+}
+-- out --
+package main
+
+templ x() {
+
{ pt1 }{ pt2 }
+}
diff --git a/parser/v2/testdata/spacing_between_string_spreads_attributes_is_kept.txt b/parser/v2/testdata/spacing_between_string_spreads_attributes_is_kept.txt
new file mode 100644
index 000000000..ed604f009
--- /dev/null
+++ b/parser/v2/testdata/spacing_between_string_spreads_attributes_is_kept.txt
@@ -0,0 +1,12 @@
+-- in --
+package main
+
+templ x() {
+
{firstName...} {lastName...}
+}
+-- out --
+package main
+
+templ x() {
+
{ firstName... } { lastName... }
+}
diff --git a/parser/v2/testdata/switch_statements_are_placed_on_a_new_line.txt b/parser/v2/testdata/switch_statements_are_placed_on_a_new_line.txt
new file mode 100644
index 000000000..bcee5f9cf
--- /dev/null
+++ b/parser/v2/testdata/switch_statements_are_placed_on_a_new_line.txt
@@ -0,0 +1,26 @@
+-- in --
+package test
+
+templ input(items []string) {
+
{ "the" }
{ "other" }
switch items[0] {
+ case "a":
+
{ items[0] }
+ case "b":
+
{ items[1] }
+}
+}
+-- out --
+package test
+
+templ input(items []string) {
+
+ { "the" }
+
{ "other" }
+ switch items[0] {
+ case "a":
+
{ items[0] }
+ case "b":
+
{ items[1] }
+ }
+
+}
diff --git a/parser/v2/testdata/tables_are_formatted_well.txt b/parser/v2/testdata/tables_are_formatted_well.txt
new file mode 100644
index 000000000..950d1cf92
--- /dev/null
+++ b/parser/v2/testdata/tables_are_formatted_well.txt
@@ -0,0 +1,30 @@
+-- in --
+package test
+
+templ table(accountNumber string, registration string) {
+
+
+
Your account number
+
{ accountNumber }
+
+
+
Registration
+
{ strings.ToUpper(registration) }
+
+
+}
+-- out --
+package test
+
+templ table(accountNumber string, registration string) {
+
+
+
Your account number
+
{ accountNumber }
+
+
+
Registration
+
{ strings.ToUpper(registration) }
+
+
+}
diff --git a/parser/v2/testdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt b/parser/v2/testdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt
new file mode 100644
index 000000000..b499007aa
--- /dev/null
+++ b/parser/v2/testdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt
@@ -0,0 +1,34 @@
+-- in --
+package main
+
+templ x(id string, class string) {
+
+}
+-- out --
+package main
+
+templ x(id string, class string) {
+
+}
diff --git a/parser/v2/testdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt b/parser/v2/testdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt
new file mode 100644
index 000000000..cc1ccfaea
--- /dev/null
+++ b/parser/v2/testdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt
@@ -0,0 +1,26 @@
+-- in --
+package main
+
+templ x() {
+