Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/heestand-xyz/WebsiteResultBuilder

Write HTML & CSS in Swift
https://github.com/heestand-xyz/WebsiteResultBuilder

Last synced: about 1 month ago
JSON representation

Write HTML & CSS in Swift

Awesome Lists containing this project

README

        

# Website Result Builder

```swift
#if os(macOS)
let desktopURL: URL = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop")
#endif

let htmlURL: URL = desktopURL.appendingPathComponent("index.html")
let html: HTML =
HTML {
Head {
Title("Test")
Link(rel: "stylesheet", href: "style.css")
}
Body {
Div(class: "test") {
"test"
"1 2 3"
}
A(id: "site", href: "http://heestand.xyz/") {
"Heestand XYZ"
}
}
}
try! html.render().write(to: htmlURL, atomically: false, encoding: .utf8)

let cssURL: URL = desktopURL.appendingPathComponent("style.css")
let css: CSS =
CSS {
Class(name: "test") {
Property.position(.absolute)
Property.backgroundColor(.black)
Property.color(.white)
}
ID(name: "site") {
Property.backgroundColor(.gray)
}
}
try! css.render().write(to: cssURL, atomically: false, encoding: .utf8)

```