Skip to content

Commit 7bf2e2c

Browse files
authored
Merge pull request #879 from feldroy/from_html
feat: migrate AirConvert functionality to air-tags by introducing `BaseTag.from_html_to_source`!
2 parents d20da11 + bba4c10 commit 7bf2e2c

27 files changed

+2571
-459
lines changed

examples/samples/__init__.py

Whitespace-only changes.
Lines changed: 84 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,94 @@
11
from typing import Final
22

3+
import air
34
from air import *
45

5-
SMALL_HTML_SAMPLE: Final = Html(
6-
Div(
7-
Link(
8-
rel="stylesheet",
9-
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css",
6+
FRAGMENT_AIR_TAG_SAMPLE: Final = air.Div(
7+
air.Meta(charset="utf-8"),
8+
air.Meta(
9+
content="width=device-width,initial-scale=1",
10+
name="viewport",
11+
),
12+
air.Title("Title!"),
13+
air.Comment("My crazy comment"),
14+
air.P(
15+
"Hello ",
16+
air.Strong("World"),
17+
"!",
18+
),
19+
)
20+
21+
TINY_AIR_TAG_SAMPLE: Final = air.Html(
22+
air.Head(
23+
air.Meta(charset="utf-8"),
24+
air.Meta(
25+
content="width=device-width,initial-scale=1",
26+
name="viewport",
1027
),
11-
Script(
12-
src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js",
13-
integrity="sha384-Akqfrbj/HpNVo8k11SXBb6TlBWmXXlYQrCSqEWmyKJe+hDm3Z/B2WVG4smwBkRVm",
14-
crossorigin="anonymous",
28+
air.Title("Title!"),
29+
air.Comment("My crazy comment"),
30+
),
31+
air.Body(
32+
air.P(
33+
"Hello",
34+
air.Strong("World"),
35+
"!",
1536
),
16-
H1("H1", data_cloud=True, data_earth="true"),
17-
H2("H1", data_cloud=True, data_earth="true"),
18-
P(
19-
A("A", data_cloud=True, data_earth="true"),
20-
A(SafeStr(":root & > < { --pico-font-size: 100%; }"), id="id1"),
21-
SafeStr("safe <> string"),
22-
A(":root & > < { --pico-font-size: 100%; }", id="id1"),
23-
Img(
24-
src="https://cdn.jsdelivr.net/dist/img.png",
25-
width=250,
26-
height=100,
27-
alt="My Img",
28-
checked=False,
29-
selected=True,
30-
bar="foo",
31-
),
32-
"<>",
33-
Script("safe <> Script", crossorigin="anonymous"),
37+
air.Div(
38+
"Div",
39+
hidden=True,
40+
draggable=True,
41+
translate="no",
42+
contenteditable=True,
43+
tabindex=3,
44+
width=12.34,
3445
),
35-
class_="class1",
36-
id="id1",
37-
style="style1",
38-
kwarg1="kwarg1",
39-
kwarg2="kwarg2",
40-
kwarg3="kwarg3",
41-
)
46+
),
47+
lang="en",
48+
)
49+
50+
SMALL_AIR_TAG_SAMPLE: Final = Html(
51+
air.Head(),
52+
air.Body(
53+
Div(
54+
Link(
55+
rel="stylesheet",
56+
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css",
57+
),
58+
Script(
59+
src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js",
60+
integrity="sha384-Akqfrbj/HpNVo8k11SXBb6TlBWmXXlYQrCSqEWmyKJe+hDm3Z/B2WVG4smwBkRVm",
61+
crossorigin="anonymous",
62+
),
63+
H1("H1", data_cloud=True, data_earth="true"),
64+
H2("H1", data_cloud=True, data_earth="true"),
65+
P(
66+
A("A", data_cloud=True, data_earth="true"),
67+
A(SafeStr(":root & > < { --pico-font-size: 100%; }"), id_="id1"),
68+
SafeStr("safe <> string"),
69+
A(":root & > < { --pico-font-size: 100%; }", id_="id1"),
70+
Img(
71+
src="https://cdn.jsdelivr.net/dist/img.png",
72+
width=250,
73+
height=100,
74+
alt="My Img",
75+
selected=True,
76+
bar="foo",
77+
),
78+
"<>",
79+
Script("safe <> Script", crossorigin="anonymous"),
80+
),
81+
class_="class1",
82+
id_="id1",
83+
style="style1",
84+
kwarg1="kwarg1",
85+
kwarg2="kwarg2",
86+
kwarg3="kwarg3",
87+
)
88+
),
4289
)
4390

44-
HTML_SAMPLE: Final = Html(
91+
AIR_TAG_SAMPLE: Final = Html(
4592
Head(
4693
Meta(
4794
property="og:image",
@@ -366,12 +413,12 @@
366413
type="text",
367414
name="q",
368415
placeholder="Enter your search query...",
369-
id="search-input",
416+
id_="search-input",
370417
),
371418
Div(class_="search-results-modal"),
372419
class_="modal-content",
373420
),
374-
id="search-modal",
421+
id_="search-modal",
375422
style="display:none;",
376423
class_="modal overflow-auto",
377424
),

0 commit comments

Comments
 (0)