Skip to content

Commit 53c48ca

Browse files
added initial logic to support streaming and other result representations and...
- `HTMLEncoding` now conforms to `Equatable`, and added `typeAnnotation` computed property
1 parent 9f9f7a5 commit 53c48ca

File tree

10 files changed

+297
-61
lines changed

10 files changed

+297
-61
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.0.3
1+
6.1.2

Sources/HTMLKit/HTMLKit.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@
1010
@freestanding(expression)
1111
public macro escapeHTML(
1212
encoding: HTMLEncoding = .string,
13+
representation: HTMLResultRepresentation = .literalOptimized,
1314
_ innerHTML: CustomStringConvertible & Sendable...
1415
) -> String = #externalMacro(module: "HTMLKitMacros", type: "EscapeHTML")
1516

1617
// MARK: HTML
1718
/// - Returns: The inferred concrete type that conforms to `CustomStringConvertible & Sendable`.
1819
@freestanding(expression)
1920
//@available(*, deprecated, message: "innerHTML is now initialized using brackets instead of parentheses")
20-
public macro html<T: CustomStringConvertible & Sendable>(
21+
public macro html<T>(
2122
encoding: HTMLEncoding = .string,
23+
representation: HTMLResultRepresentation = .literalOptimized,
2224
lookupFiles: [StaticString] = [],
2325
_ innerHTML: CustomStringConvertible & Sendable...
2426
) -> T = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
2527

2628
// MARK: HTML
2729
/// - Returns: The inferred concrete type that conforms to `CustomStringConvertible & Sendable`.
2830
@freestanding(expression)
29-
public macro html<T: CustomStringConvertible & Sendable>(
31+
public macro html<T>(
3032
encoding: HTMLEncoding = .string,
33+
representation: HTMLResultRepresentation = .literalOptimized,
3134
lookupFiles: [StaticString] = [],
3235
_ innerHTML: () -> CustomStringConvertible & Sendable...
3336
) -> T = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
@@ -36,6 +39,7 @@ public macro html<T: CustomStringConvertible & Sendable>(
3639
@freestanding(expression)
3740
public macro anyHTML(
3841
encoding: HTMLEncoding = .string,
42+
representation: HTMLResultRepresentation = .literalOptimized,
3943
lookupFiles: [StaticString] = [],
4044
_ innerHTML: CustomStringConvertible & Sendable...
4145
) -> any CustomStringConvertible & Sendable = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
@@ -47,6 +51,7 @@ public macro anyHTML(
4751
@freestanding(expression)
4852
public macro uncheckedHTML<T: CustomStringConvertible & Sendable>(
4953
encoding: HTMLEncoding = .string,
54+
representation: HTMLResultRepresentation = .literalOptimized,
5055
lookupFiles: [StaticString] = [],
5156
_ innerHTML: CustomStringConvertible & Sendable...
5257
) -> T = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
@@ -58,6 +63,7 @@ public macro uncheckedHTML<T: CustomStringConvertible & Sendable>(
5863
@freestanding(expression)
5964
public macro rawHTML<T: CustomStringConvertible & Sendable>(
6065
encoding: HTMLEncoding = .string,
66+
representation: HTMLResultRepresentation = .literalOptimized,
6167
lookupFiles: [StaticString] = [],
6268
minify: Bool = false,
6369
_ innerHTML: CustomStringConvertible & Sendable...
@@ -69,6 +75,7 @@ public macro rawHTML<T: CustomStringConvertible & Sendable>(
6975
@freestanding(expression)
7076
public macro anyRawHTML(
7177
encoding: HTMLEncoding = .string,
78+
representation: HTMLResultRepresentation = .literalOptimized,
7279
lookupFiles: [StaticString] = [],
7380
minify: Bool = false,
7481
_ innerHTML: CustomStringConvertible & Sendable...

Sources/HTMLKitMacros/EscapeHTML.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum EscapeHTML: ExpressionMacro {
1111
expansion: node,
1212
ignoresCompilerWarnings: false,
1313
encoding: .string,
14+
representation: .literalOptimized,
1415
key: "",
1516
arguments: node.arguments,
1617
escape: true,

Sources/HTMLKitMacros/HTMLElement.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum HTMLElementMacro: ExpressionMacro {
1212
expansion: node,
1313
ignoresCompilerWarnings: node.macroName.text == "uncheckedHTML",
1414
encoding: .string,
15+
representation: .literalOptimized,
1516
key: "",
1617
arguments: node.arguments,
1718
escape: true,

Sources/HTMLKitMacros/RawHTML.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum RawHTML: ExpressionMacro {
1111
expansion: node,
1212
ignoresCompilerWarnings: false,
1313
encoding: .string,
14+
representation: .literalOptimized,
1415
key: "",
1516
arguments: node.arguments,
1617
escape: false,

0 commit comments

Comments
 (0)