Swiftpack.co - atacan/html-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by atacan.
atacan/html-swift 2.0.2
Convert HTML to Swift code
⭐️ 2
🕓 1 year ago
macOS
.package(url: "https://github.com/atacan/html-swift.git", from: "2.0.2")

Html-Swift

Input an Html code and get the Swift code for the following DSLs

to generate that Html code.

How to Use it

Mac App

https://github.com/atacan/Dime-a-Dozen

Package

import HtmlSwift
let htmlInput = """
<a href="url">link text</a>
<br>
"""
try convertToPointFree(html: htmlInput)

.html(
    .head(
    ),
    .body(
        .a(
            attributes: [
                .href("url"),
            ],
            "link text"
        ),
        .br
    )
)

or

try convertToBinaryBirds(html: htmlInput)

Html {
    Head()
    Body {
        A("link text")
            .href("url")
        Br()
    }
}

Use Cases

  • You have an html code base, maybe with a templating language, but you want to switch to pure Swift DSL.
  • You are using a CSS framework such as Bootstrap, and you copy paste the ready-made components you find.

Without a converter, the only way to switch to the DSL world is to look at your html code on one side and type the Swift code for it on the other side.

Contribution

  • Tests are incomplete. We need to test all the elements and attributes
  • The code has a lot of repeated components. Those can be put in functions maybe.

Credits

Inspired by and adapted from HTMLKit

GitHub

link
Stars: 2
Last commit: 41 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics