Hey <@U04V0U8VA2X>, thanks for the request. We hav...
# kotlinx-html
e
Hey @Cies, thanks for the request. We have prototyped htmx support some time ago and will publish an update soon 🙂
c
@e5l we'll wait it out then 🙂 thanks! (not for me though, we barely use HTML-fragments in our codebase)
r
Here's a couple snippets from my codebase, which uses htmx/kotlinx.html:
Copy code
@GET("/subscribe_banner")
    fun getSubscribeBanner(ctx: Context) = ctx.fragment(DashboardPage.subscribeTarget) {
        subscribeBanner(billingApi)
    }
I use server side targeting, which gives me nice type safety
or, for a whole page:
Copy code
@GET()
fun get(ctx: Context) = ctx.page(dashboardTemplate, "My App", listOf {
    ... 
    val currentSubscription = paymentDAO.getCurrentSubscription(userWithSub)
    renderDashboard(currentSubscription, this@DashboardApi)
})
The templates have a number of slots, which the list renders into. The string is the title to use on the page. Also, all pages use hx-boost, so even this is using htmx.
And then the actual render functions are like this:
Copy code
fun html.renderDashboard(currentSubscription: Subscription?, api: DashboardApi) {

        if (currentSubscription == null) {
            span {
                zone(subscribeTarget)
                onLoad(withAction(api::getSubscribeBanner, swap = HTMX.Swap.OUTER))
            }
        }

        span {
            zone(gridTarget)
            onLoad(withAction(api::getDashboardBase, swap = HTMX.Swap.OUTER))
        }
    }