Kotlin / kotlinx.html

Kotlin DSL for HTML
Apache License 2.0
1.6k stars 130 forks source link

Improve the documentation on custom tags #244

Open reubenfirmin opened 10 months ago

reubenfirmin commented 10 months ago

It's pretty barebones: https://github.com/Kotlin/kotlinx.html/wiki/Micro-templating-and-DSL-customizing

How do we add custom attributes? StringAttribute exists and seems to be the thing, but there are no examples of how to use it, and no javadoc.

Let's take the following example as something we want to be able to do based on the docs. SVG is incomplete, so we want to be able to extend it in order to support the following:

                    svg("w-6 h-6") {
                        fill = "currentColor"
                        viewbox = "0 0 20 20"
                        xmlns = "http://www.w3.org/2000/svg"
                        path {
                             fillRule = "evenodd"
                             d =
                                 "M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
                             clipRule = "evenodd"
                         }
                     }

How do we even start? The docs should give us enough information to understand how to proceed.