Skip to content

Commit

Permalink
breaking changes
Browse files Browse the repository at this point in the history
- attributes are now parsed the same as extra attributes, which allowed me to replace the `attributes` label with proper global attribute labels
- attempted to improve performance by inlining some single-use functions, avoiding O(n) complexity functions, and removing some branching
  • Loading branch information
RandomHashTags committed Sep 19, 2024
1 parent f5231ea commit 3399db3
Show file tree
Hide file tree
Showing 5 changed files with 4,108 additions and 383 deletions.
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ let package = Package(
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax")
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
]
),
.target(
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ Write HTML using Swift Macros.
- Swift Macros are powerful and offer performance benefits
- 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)
- HTML macros enforce safety, can be used anywhere, and compile directly to strings which are easily manipulated
- The compiled output already minified
- The output is already minified at no performance cost
### Examples
```swift
let test:String = #html([
#body([
#div(
attributes: [
.class(["dark", "mode"]),
.title("Hover over message"),
.draggable(.false),
.inputMode(.email),
.hidden(.hidden)
],
class: ["bing", "bong"],
draggable: .false,
hidden: .hidden,
inputmode: .email,
title: "just seeing what blow's",
[
"Random text",
#div(),
#a([#div([#abbr()])]),
#a([
#div([
#abbr()
]),
#address()
]),
#div(),
#button(disabled: true),
#video(autoplay: true, controls: false, height: nil, preload: .auto, src: "ezclap", width: 5),
#video(autoplay: true, controls: false, height: nil, preload: .auto, src: "https://github.com/RandomHashTags/litleagues", width: .centimeters(1)),
]
)
])
Expand Down
Loading

0 comments on commit 3399db3

Please sign in to comment.