【发布时间】:2021-12-30 05:25:44
【问题描述】:
我在我的 ktor 项目中使用 HTML DSL 作为模板引擎。 我正在尝试将其中一个子模板模板作为文本响应发送(我不想发送完整的 HtmlTemplate)。
到目前为止,我得到了以下信息 - 为了使其工作,我必须将我的 TestTemplate 包装在另一个 div 中:
fun Route.test() {
get("/test") {
call.respondText(
buildString {
appendHTML().div {
insert(TestTemplate(), TemplatePlaceholder())
}
}
)
}
}
这给了我以下响应(内部 div 是我的 TestTemplate):
<div>
<div>this is the element I want to get, without the outer element</div>
</div>
我想得到的只是 TestTemplate:
<div>this is the element I want to get, without the outer element</div>
有没有办法使用 HTML DSL 在 ktor 中实现它?
【问题讨论】:
标签: ktor