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
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ Write HTML using Swift Macros.
3
3
<ahref="https://swift.org"><imgsrc="https://img.shields.io/badge/Swift-5.9+-orange"alt="Requires at least Swift 5.9"></a> <imgsrc="https://img.shields.io/badge/Platforms-Any-gold"> <ahref="https://github.com/RandomHashTags/swift-htmlkit/blob/main/LICENSE"><imgsrc="https://img.shields.io/badge/License-Apache_2.0-blue"alt="Apache 2.0 License">
4
4
5
5
-[Why](#why)
6
-
-[Examples](#examples)
6
+
-[Usage](#usage)
7
7
-[Basic](#basic)
8
8
-[Advanced](#advanced)
9
9
-[Benchmarks](#benchmarks)
@@ -17,7 +17,7 @@ Write HTML using Swift Macros.
17
17
- Alternative libraries may not fit all situations and may restrict how the html is generated, manipulated, prone to human error, or cost a constant performance overhead (middleware, rendering, result builders, etc)
18
18
- HTML macros enforce safety, can be used anywhere, and compile directly to strings
19
19
- The output is minified at no performance cost
20
-
## Examples
20
+
## Usage
21
21
### Basic
22
22
<details>
23
23
<summary>How do I use this library?</summary>
@@ -83,6 +83,9 @@ If you know the data **at compile time** (and not working with HTML macros):
83
83
-`#escapeHTML()` macro
84
84
85
85
If you're working with **runtime** data:
86
+
87
+
> \>\>\> !! You need to `import HTMLKitUtilities` to use these functions !! <<<
88
+
86
89
-`<string>.escapeHTML(escapeAttributes:)`
87
90
- mutates `self` escaping HTML and, optionally, attribute characters
88
91
-`<string>.escapeHTMLAttributes()`
@@ -172,6 +175,19 @@ Use the `HTMLElementAttribute.event(<type>, "<value>")`.
172
175
```
173
176
</details>
174
177
178
+
<details>
179
+
<summary>I need the output as a different type!</summary>
180
+
181
+
Use a different html macro. Currently supported types (more to come with new language features):
182
+
-`#html()` -> `String`/`StaticString`
183
+
-`#htmlUTF8Bytes()` -> `[UInt8]`
184
+
-`#htmlUTF16Bytes()` -> `[UInt16]`
185
+
-`#htmlUTF8CString()` -> `ContiguousArray<CChar>`
186
+
-`#htmlData()` -> `Foundation.Data`
187
+
-`#htmlByteBuffer()` -> `NIOCore.ByteBuffer`
188
+
189
+
</details>
190
+
175
191
## Benchmarks
176
192
- Libraries tested
177
193
-[BinaryBuilds/swift-html](https://github.com/BinaryBirds/swift-html) v1.7.0 (patched version [here](https://github.com/RandomHashTags/fork-bb-swift-html))
0 commit comments