@@ -18,7 +18,7 @@ import struct NIOCore.ByteBuffer
1818
1919enum HTMLElement : ExpressionMacro {
2020 static func expansion( of node: some FreestandingMacroExpansionSyntax , in context: some MacroExpansionContext ) throws -> ExprSyntax {
21- let string : String = parse_macro ( context: context, expression : node. macroExpansion!)
21+ let string : String = expand_macro ( context: context, macro : node. macroExpansion!)
2222 var set : Set < HTMLElementType ? > = [ . htmlUTF8Bytes, . htmlUTF16Bytes, . htmlUTF8CString, . htmlByteBuffer]
2323
2424 #if canImport(Foundation)
@@ -58,10 +58,12 @@ enum HTMLElement : ExpressionMacro {
5858}
5959
6060private extension HTMLElement {
61- // MARK: Parse Macro
62- static func parse_macro( context: some MacroExpansionContext , expression: MacroExpansionExprSyntax ) -> String {
63- guard let elementType: HTMLElementType = HTMLElementType ( rawValue: expression. macroName. text) else { return " \( expression) " }
64- let childs : SyntaxChildren = expression. arguments. children ( viewMode: . all)
61+ // MARK: Expand Macro
62+ static func expand_macro( context: some MacroExpansionContext , macro: MacroExpansionExprSyntax ) -> String {
63+ guard let elementType: HTMLElementType = HTMLElementType ( rawValue: macro. macroName. text) else {
64+ return " \( macro) "
65+ }
66+ let childs : SyntaxChildren = macro. arguments. children ( viewMode: . all)
6567 if elementType == . escapeHTML {
6668 return childs. compactMap ( {
6769 guard let child: LabeledExprSyntax = $0. labeled else { return nil }
@@ -167,7 +169,7 @@ private extension HTMLElement {
167169 // MARK: Parse innerHTML
168170 static func parse_inner_html( context: some MacroExpansionContext , elementType: HTMLElementType , child: LabeledExprSyntax ) -> String ? {
169171 if let macro: MacroExpansionExprSyntax = child. expression. macroExpansion {
170- var string : String = parse_macro ( context: context, expression : macro)
172+ var string : String = expand_macro ( context: context, macro : macro)
171173 if elementType == . escapeHTML {
172174 string. escapeHTML ( escapeAttributes: false )
173175 }
0 commit comments