Skip to content

Commit e1a7184

Browse files
Merge pull request #14 from RandomHashTags/support-trailing-closure-for-uncheckedHTML
support trailing closure syntax for `#uncheckedHTML` macro
2 parents fb529a4 + c6406d4 commit e1a7184

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Sources/HTMLKit/HTMLKit.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public macro uncheckedHTML<T>(
4949
_ innerHTML: Sendable...
5050
) -> T = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
5151

52+
/// Same as `#html` but ignoring compiler warnings.
53+
///
54+
/// - Returns: The inferred concrete type.
55+
@freestanding(expression)
56+
public macro uncheckedHTML<T>(
57+
encoding: HTMLEncoding = .string,
58+
resultType: HTMLExpansionResultType = .literal,
59+
lookupFiles: [StaticString] = [],
60+
_ innerHTML: () -> Sendable...
61+
) -> T = #externalMacro(module: "HTMLKitMacros", type: "HTMLElementMacro")
62+
5263
// MARK: Raw
5364
/// Does not escape the `innerHTML`.
5465
///

Tests/HTMLKitTests/InterpolationTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ extension InterpolationTests {
335335

336336
@Test func uncheckedInterpolation() {
337337
let _:String = #uncheckedHTML(encoding: .string, div(InterpolationTests.patrick))
338+
let _:String = #uncheckedHTML(encoding: .string) {
339+
div(InterpolationTests.patrick)
340+
}
338341
}
339342

340343
@Test func closureInterpolation() {

0 commit comments

Comments
 (0)