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
<element specific attribute>:<element specific attribute value>?,
34
+
_ innerHTML:ExpressibleByStringLiteral...
35
+
)
36
+
37
+
```
38
+
39
+
- all parameters are optional by default
40
+
28
41
#### Examples
29
42
30
43
```swift
@@ -104,20 +117,26 @@ Using String Interpolation.
104
117
105
118
> You will get a compiler warning saying *interpolation may introduce raw HTML*.
106
119
>
107
-
> Its up to you whether or not to suppress this warning or escape the HTML at runtime using an method described above.
120
+
> Its up to you whether or not to suppress this warning or escape the HTML at runtime using a method described above.
108
121
>
109
122
> Swift HTMLKit tries to [replace](https://github.com/RandomHashTags/swift-htmlkit/blob/94793984763308ef5275dd9f71ea0b5e83fea417/Sources/HTMLKitMacros/HTMLElement.swift#L423) known interpolation at compile time with a compile time equivalent for the best performance. It is currently limited due to macro expansions being sandboxed and lexical contexts/AST not being available for macro arguments. This means referencing content known at compile time in a html macro won't get replaced by its literal contents. [Read more about this limitation](https://forums.swift.org/t/swift-lexical-lookup-for-referenced-stuff-located-outside-scope-current-file/75776/6).
110
123
111
124
#### Example
112
125
```swift
113
126
let string:String="any string value", integer:Int=-69, float:Float=3.141592
114
127
128
+
// ✅ DO
115
129
let _:String=#p("\(string); \(integer); \(float)")
116
130
let _:String=#p("\(string)", "; ", String(describing: integer), "; ", float.description)
117
-
// the below also works
131
+
118
132
let integer_string:String=String(describing: integer), float_string:String=String(describing: float)
119
133
let _:String=#p(string, "; ", integer_string, "; ", float_string)
120
134
135
+
// ❌ DON'T; compiler error; compile time value cannot contain interpolation
136
+
let _:StaticString=#p("\(string); \(integer); \(float)")
137
+
let _:StaticString=#p("\(string)", "; ", String(describing: integer), "; ", float.description)
138
+
let _:StaticString=#p(string, "; ", integer_string, "; ", float_string)
139
+
121
140
```
122
141
123
142
</details>
@@ -194,7 +213,7 @@ Use a different html macro. Currently supported types (more to come with new lan
194
213
195
214
<summary>How do I use HTMX?</summary>
196
215
197
-
Use the `.htmx(<htmx attribute>)` global attribute. All HTMX 2.0 attributes are supported (including web socket).
216
+
Use the `.htmx(<htmx attribute>)` global attribute. All HTMX 2.0 attributes are supported (including Server Sent Events & Web Sockets).
0 commit comments