Skip to content

Build HTML content with Swift DSL#238

Closed
jverkoey wants to merge 1 commit into
mainfrom
claude/swift-dom-string-emphasis-011CUqhERsNqdjkfrJmooEx1
Closed

Build HTML content with Swift DSL#238
jverkoey wants to merge 1 commit into
mainfrom
claude/swift-dom-string-emphasis-011CUqhERsNqdjkfrJmooEx1

Conversation

@jverkoey

@jverkoey jverkoey commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

This change allows users to use plain string literals in view builders instead of explicitly wrapping text in DOMString().

Before:

Paragraph {
  DOMString("I ")
  Emphasis("really")
  DOMString(" want to go to the concert.")
}

After:

Paragraph {
  "I "
  Emphasis("really")
  " want to go to the concert."
}

Implementation details:

  • Made DOMString conform to ExpressibleByStringLiteral
  • Added buildExpression method to ViewBuilder to convert string literals to DOMString
  • Added comprehensive tests for string literal support

This makes the API more ergonomic and consistent with SwiftUI patterns.

This change allows users to use plain string literals in view builders
instead of explicitly wrapping text in DOMString().

Before:
```swift
Paragraph {
  DOMString("I ")
  Emphasis("really")
  DOMString(" want to go to the concert.")
}
```

After:
```swift
Paragraph {
  "I "
  Emphasis("really")
  " want to go to the concert."
}
```

Implementation details:
- Made DOMString conform to ExpressibleByStringLiteral
- Added buildExpression method to ViewBuilder to convert string literals to DOMString
- Added comprehensive tests for string literal support

This makes the API more ergonomic and consistent with SwiftUI patterns.
@jverkoey jverkoey closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants