Skip to content

daymxn/kHTML

Repository files navigation

kHTML logo

GitHub release (latest by date) GitHub last commit (branch) GitHub issues GitHub code size in bytes GitHub

kHTML

Super light-weight HTML5 DSL written in pure Kotlin!

Learn how to use kHTML by reading our wiki here.

Example

fun makeUserDisplay(users: List<String>) =
    html {
        body {
            this write users.map { userEntry(it) }
        }
    }

fun userEntry(name: String) =
    div {
        p {
            this write "Hello! My name is $name"
        }
    }

Installation

Unfortunately, kHTML artifacts are not currently available on maven central. The reasoning for this can be found here.

For the time being, you can pull kHTML artifacts from GitHub Packages.

Gradle

implementation("com.daymxn:khtml:1.0.0")

Maven

<dependency>
  <groupId>com.daymxn</groupId>
  <artifactId>khtml</artifactId>
  <version>1.0.0</version>
</dependency>

Notable features

  • 1:1 Mapping between HTML elements and Kotlin classes
  • Easily compile kHTML elements to string representations of HTML5
  • Functional element creation support
  • Fully documented API
  • Modular API to allow easy extendability
  • Lightweight DSL

Roadmap

  • Add unit tests
  • Add support for additional common HTML5 elements
  • Extend elements to offer all props typically offered from their HTML counterpart

Getting Started

Basics

Adding Text

Functional Elements

More Functional Elements

Configuring Elements

Adding custom Tags

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

License

Apache 2.0