Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kotlin/kotlinx.html
Kotlin DSL for HTML
https://github.com/Kotlin/kotlinx.html
dsl html kotlin
Last synced: 9 days ago
JSON representation
Kotlin DSL for HTML
- Host: GitHub
- URL: https://github.com/Kotlin/kotlinx.html
- Owner: Kotlin
- License: apache-2.0
- Created: 2015-04-02T09:44:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T07:36:51.000Z (about 1 month ago)
- Last Synced: 2024-10-23T01:58:02.257Z (14 days ago)
- Topics: dsl, html, kotlin
- Language: Kotlin
- Homepage:
- Size: 1.82 MB
- Stars: 1,624
- Watchers: 49
- Forks: 132
- Open Issues: 85
-
Metadata Files:
- Readme: README-JS.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-kotlin - kotlinx.html - Kotlin DSL for HTML (Libraries)
- awesome-ccamel - Kotlin/kotlinx.html - Kotlin DSL for HTML (Kotlin)
README
# kotlinx.html
A kotlinx.html library provides DSL to build HTML to [Writer](https://docs.oracle.com/javase/8/docs/api/java/io/Writer.html)/[Appendable](https://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html) or DOM at JVM and browser (or other JavaScript engine) for
better [Kotlin programming](https://kotlinlang.org) for Web.# Get started
See [Getting started](https://github.com/kotlin/kotlinx.html/wiki/Getting-started) page for details how to include the library.
# DOM
You can build DOM tree with JVM and JS naturallySee example for JavaScript-targeted Kotlin
```kotlin
window.setInterval({
val myDiv = document.create.div("panel") {
p {
+"Here is "
a("https://kotlinlang.org") { +"official Kotlin site" }
}
}document.getElementById("container")!!.appendChild(myDiv)
document.getElementById("container")!!.append {
div {
+"added it"
}
}
}, 1000L)
```# Stream
You can build HTML directly to Writer (JVM only) or Appendable (both JVM and JS)```kotlin
System.out.appendHTML().html {
body {
div {
a("https://kotlinlang.org") {
target = ATarget.blank
+"Main site"
}
}
}
}
```# Documentation
See [wiki](https://github.com/kotlin/kotlinx.html/wiki) pages
# Building
See [development](https://github.com/kotlin/kotlinx.html/wiki/Development) page for details# Old version
See https://github.com/kotlinx/kotlinx.html.legacy for older version. We strongly recommend to migrate to latest version.