Skip to content

Instantly share code, notes, and snippets.

@jaredkhan
Last active November 6, 2017 17:27
Show Gist options
  • Save jaredkhan/1e930c0aeec4379366e98bf96705477d to your computer and use it in GitHub Desktop.
Save jaredkhan/1e930c0aeec4379366e98bf96705477d to your computer and use it in GitHub Desktop.
Swift HTML Builder Example
struct ImageHero: Nodeable {
let background: BackgroundType
let imagePath: String
let alternateText: String
var node: Node {
return El.Div[
Attr.className => "ImageHero",
Attr.style => background.style
].containing(
El.Div[
Attr.className => "ImageHero__image",
Attr.style => ["background-image": "url('\(imagePath)')"]
],
El.Div[
Attr.className => "Text--screenReader"
].containing(alternateText)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment