Skip to content

Instantly share code, notes, and snippets.

@asarazan
Last active September 26, 2018 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asarazan/c7847a612bb052bce972fdcffcc5fa0d to your computer and use it in GitHub Desktop.
Save asarazan/c7847a612bb052bce972fdcffcc5fa0d to your computer and use it in GitHub Desktop.
fun html(init: HTML.() -> Unit): HTML {
val html = HTML()
html.init()
return html
}
fun HTML.head(init: Head.() -> Unit) : Head {
val head = Head()
head.init()
children.add(head)
return head
}
fun HTML.body(init: Body.() -> Unit) : Body {
val body = Body()
body.init()
children.add(body)
return body
}
fun [Parent Object].html(init: [Thing You're Building].() -> Unit): [Thing You're Building] {
val thing = ["Thing You're Building"]()
thing.init()
return thing
}
fun [Parent Object].head(init: [Thing You're Building].() -> Unit) : [Thing You're Building] {
val thing = [Thing You're Building]()
thing.init()
/* Do some stuff with the parent */
return thing
}
fun [Parent Object].body(init: [Thing You're Building].() -> Unit) : [Thing You're Building] {
val thing = [Thing You're Building]()
thing.init()
/* Do some stuff with the parent */
return thing
}
fun html(████: HTML.██ ██ ████): HTML {
val ████ = HTML()
████.████()
return ████
}
fun ████.head(████: Head.██ ██ ████) : Head {
val ████ = Head()
████.████()
children.add(████)
return ████
}
fun ████.body(████: Body.██ ██ ████) : Body {
val ████ = Body()
████.████()
children.add(████)
return ████
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment