e5l
10/16/2024, 7:07 AMCies
10/16/2024, 7:22 AMReuben Firmin
10/16/2024, 10:48 AMReuben Firmin
10/16/2024, 10:48 AM@GET("/subscribe_banner")
fun getSubscribeBanner(ctx: Context) = ctx.fragment(DashboardPage.subscribeTarget) {
subscribeBanner(billingApi)
}
I use server side targeting, which gives me nice type safetyReuben Firmin
10/16/2024, 10:49 AM@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.Reuben Firmin
10/16/2024, 10:50 AMfun 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))
}
}