Skip to content

Commit b7bfe25

Browse files
Forgot formatter again, cast(tomato, tomatoe)
1 parent de4c17b commit b7bfe25

File tree

2 files changed

+79
-50
lines changed

2 files changed

+79
-50
lines changed

tdom/transformer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,5 +1124,3 @@ def _transform_template(self, cached_template: CachableTemplate) -> Template:
11241124
def transform_template(self, template: Template) -> Template:
11251125
ct = CachableTemplate(template)
11261126
return self._transform_template(ct)
1127-
1128-

tdom/transformer_test.py

Lines changed: 79 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -562,62 +562,93 @@ def Comp() -> Element:
562562

563563
def test_node_api_smoketest(node_api):
564564
def HeadingTitle(children: Template) -> Template:
565-
return t'<h1>{children}</h1>'
565+
return t"<h1>{children}</h1>"
566+
566567
head_title = "Smoketest was the <title>"
567568
heading_title = "Smoketest > Firetest"
568569
comment_when = "--> Tomorrow!"
569570
fav_nums = [3, 7]
570571
alert_message = "After this is a </script>!"
571572
# @TODO: We might need some whitespace coping mechanisms.
572-
page_t = (t"<!doctype html>"
573-
t'<html lang="en">'
573+
page_t = (
574+
t"<!doctype html>"
575+
t'<html lang="en">'
574576
t"<head>"
575-
t'<meta charset="utf8">'
576-
t"<title>{head_title}</title>"
577+
t'<meta charset="utf8">'
578+
t"<title>{head_title}</title>"
577579
t"</head>"
578580
t"<body>"
579-
t"<{HeadingTitle}><span>*</span>{heading_title}</{HeadingTitle}>"
580-
t"<!-- Put more content in here {comment_when} -->"
581-
t"<h2>Favorite Numbers</h2>"
582-
t"<ul>{ [t'<li>{num}</li>' for num in fav_nums] }</ul>"
583-
t'<button id="alert-button">Alert!</button>'
584-
t'<script>document.getElementById("alert-button").addEventListener("click", function (e) {{ alert("{alert_message}"); }})</script>'
581+
t"<{HeadingTitle}><span>*</span>{heading_title}</{HeadingTitle}>"
582+
t"<!-- Put more content in here {comment_when} -->"
583+
t"<h2>Favorite Numbers</h2>"
584+
t"<ul>{[t'<li>{num}</li>' for num in fav_nums]}</ul>"
585+
t'<button id="alert-button">Alert!</button>'
586+
t'<script>document.getElementById("alert-button").addEventListener("click", function (e) {{ alert("{alert_message}"); }})</script>'
585587
t"</body>"
586-
t"</html>")
588+
t"</html>"
589+
)
587590
node = node_api.make_node_from_template(page_t)
588-
assert node == Fragment(children=[
589-
DocumentType("html"),
590-
Element("html", attrs={"lang": "en"}, children=[
591-
Element("head", children=[
592-
Element("meta", attrs={"charset": "utf8"}),
593-
Element("title", children=[
594-
Text("Smoketest was the <title>")
595-
]),
596-
]),
597-
Element("body", children=[
598-
Element("h1", children=[
599-
Element("span", children=[
600-
Text("*")
601-
]),
602-
Text("Smoketest > Firetest"),
603-
]),
604-
Comment(" Put more content in here --> Tomorrow! "),
605-
Element("h2", children=[
606-
Text("Favorite Numbers")]),
607-
Element("ul", children=[
608-
Element("li", children=[
609-
Text("3"),
610-
]),
611-
Element("li", children=[
612-
Text("7"),
613-
]),
614-
]),
615-
Element("button", {"id": "alert-button"}, children=[
616-
Text("Alert!")
617-
]),
618-
Element("script", children=[
619-
Text('document.getElementById("alert-button").addEventListener("click", function (e) { alert("After this is a </script>!"); })')
620-
]),
621-
]),
622-
]),
623-
])
591+
assert node == Fragment(
592+
children=[
593+
DocumentType("html"),
594+
Element(
595+
"html",
596+
attrs={"lang": "en"},
597+
children=[
598+
Element(
599+
"head",
600+
children=[
601+
Element("meta", attrs={"charset": "utf8"}),
602+
Element(
603+
"title", children=[Text("Smoketest was the <title>")]
604+
),
605+
],
606+
),
607+
Element(
608+
"body",
609+
children=[
610+
Element(
611+
"h1",
612+
children=[
613+
Element("span", children=[Text("*")]),
614+
Text("Smoketest > Firetest"),
615+
],
616+
),
617+
Comment(" Put more content in here --> Tomorrow! "),
618+
Element("h2", children=[Text("Favorite Numbers")]),
619+
Element(
620+
"ul",
621+
children=[
622+
Element(
623+
"li",
624+
children=[
625+
Text("3"),
626+
],
627+
),
628+
Element(
629+
"li",
630+
children=[
631+
Text("7"),
632+
],
633+
),
634+
],
635+
),
636+
Element(
637+
"button",
638+
{"id": "alert-button"},
639+
children=[Text("Alert!")],
640+
),
641+
Element(
642+
"script",
643+
children=[
644+
Text(
645+
'document.getElementById("alert-button").addEventListener("click", function (e) { alert("After this is a </script>!"); })'
646+
)
647+
],
648+
),
649+
],
650+
),
651+
],
652+
),
653+
]
654+
)

0 commit comments

Comments
 (0)