org.http4k.template.DatastarFragmentRenderer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-web-datastar Show documentation
Show all versions of http4k-web-datastar Show documentation
http4k Datastar support utilities
The newest version!
package org.http4k.template
import org.http4k.datastar.Fragment
/**
* Renderer which converts a ViewModel into Datastar Fragments
*/
class DatastarFragmentRenderer(private val renderer: TemplateRenderer) {
operator fun invoke(vararg views: ViewModel) = views.map { Fragment.of(renderer(it).stripNewLines()) }
private fun String.stripNewLines() = replace("\n", "")
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy