You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-11Lines changed: 57 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,21 +28,45 @@ Write HTML using Swift Macros. Supports HTMX via global attributes.
28
28
<details>
29
29
<summary>How do I use this library?</summary>
30
30
31
-
Use the `#html(encoding:attributes:innerHTML:)` macro. All parameters, for the macro and default HTML elements, are optional by default. The default HTML elements are generated by an internal macro.
31
+
Use the `#html(encoding:lookupFiles:innerHTML:)` macro. All parameters, for the macro and default HTML elements, are optional by default. The default HTML elements are generated by an internal macro.
32
32
33
-
#### HTML Macro
33
+
#### Macros
34
+
35
+
<details>
36
+
<summary>html</summary>
37
+
38
+
Requires explicit type annotation due to returning the inferred concrete type.
34
39
35
40
```swift
36
41
37
-
#html(
42
+
#html<T:CustomStringConvertible>(
38
43
encoding: HTMLEncoding = .string,
39
-
attributes: [<global attribute>] = [],
40
-
<element specific attribute>:<element specific attribute value>?=nil,
41
-
_ innerHTML:CustomStringConvertible...
44
+
lookupFiles: [StaticString] = [],
45
+
_ innerHTML:CustomStringConvertible& Sendable...
46
+
) -> T
47
+
48
+
```
49
+
50
+
</details>
51
+
52
+
<details>
53
+
54
+
<summary>anyHTML</summary>
55
+
56
+
Same as `#html` but returning an existential.
57
+
58
+
```swift
59
+
60
+
#anyHTML(
61
+
encoding: HTMLEncoding = .string,
62
+
lookupFiles: [StaticString] = [],
63
+
_ innerHTML:CustomStringConvertible& Sendable...
42
64
)
43
65
44
66
```
45
67
68
+
</details>
69
+
46
70
#### HTMLElement
47
71
48
72
All default HTML elements conform to the `HTMLElement` protocol and contain their appropriate element attributes. They can be declared when you initialize the element or be changed after initialization by accessing the attribute variable directly.
@@ -54,7 +78,7 @@ The default initializer for creating an HTML Element follows this syntax:
54
78
<html element name>(
55
79
attributes: [<global attribute>] = [],
56
80
<element specific attribute>:<value>?=nil,
57
-
_ innerHTML:CustomStringConvertible...
81
+
_ innerHTML:CustomStringConvertible& Sendable...
58
82
)
59
83
60
84
```
@@ -272,18 +296,40 @@ Declare the encoding you want in the `#html` macro.
0 commit comments