Mikael Ståldal
07/02/2023, 2:59 PMhttp4k-template-thymeleaf
look for templates with .html
suffix? I am trying this:
data class Person(val name: String, val age: Int) : ViewModel
fun main() {
val renderer = ThymeleafTemplates().CachingClasspath("templates")
val app: HttpHandler = {
val viewModel = Person("Bob", 45)
Response(OK).body(renderer(viewModel))
}
app.asServer(SunHttp(8000)).start()
}
but it expects the template file to be Person
(without suffix), I want it to be Person.html
.dave
07/02/2023, 3:03 PMMikael Ståldal
07/02/2023, 3:07 PMMikael Ståldal
07/02/2023, 5:42 PMs4nchez
07/02/2023, 8:17 PMgypsydave5
07/03/2023, 7:58 AMs4nchez
07/03/2023, 8:17 AMgypsydave5
07/03/2023, 8:18 AMgypsydave5
07/03/2023, 8:18 AMMikael Ståldal
07/03/2023, 8:49 AMfooter.html
, and refer to them with
th:insert="~{footer :: copy}"
but, I need to do
th:insert="~{footer.html :: copy}"
or rename the file to footer
(without suffix).
So it seems like Thymeleaf expect the integrating framework to add a .html
suffix automagically, which http4k does not.dave
07/03/2023, 9:06 AMMikael Ståldal
07/03/2023, 9:08 AMMikael Ståldal
07/03/2023, 9:18 AMMikael Ståldal
07/03/2023, 3:09 PMMikael Ståldal
07/04/2023, 8:06 AMval renderer = ThymeleafTemplates().CachingClasspath("templates")
val htmlLens = Body.viewModel(renderer, TEXT_HTML).toLens()
It would make sense if this also set .html
suffix on the templates (which seems to be the convention for Thymeleaf), and maybe also templateResolver.setTemplateMode(TemplateMode.HTML)
.Mikael Ståldal
07/04/2023, 8:08 AMMikael Ståldal
07/05/2023, 10:02 AM.html
suffix by default for Thymeleaf templates: https://github.com/http4k/http4k/pull/942