gpt4 book ai didi

使用 Groovy MarkupBuilder 的 HTML,我如何优雅地混合标签和文本?

转载 作者:搜寻专家 更新时间:2023-10-31 22:10:11 26 4
gpt4 key购买 nike

当使用 Groovy MarkupBuilder 时,我有一些地方需要将文本输出到文档中,或者调用一个将文本输出到文档中的函数。目前,我正在使用未定义的标签 "text" 进行输出。有没有更好的方法来编写这段代码?

li {
text("${type.getAlias()} blah blah ")
function1(type.getXYZ())
if (type instanceof Class1) {
text(" implements ")
ft.getList().each {
if (it == '') return
text(it)
if (!function2(type, it)) text(", ")
}
}
}

最佳答案

其实现在推荐的方式是使用mkp.yield,例如

src.p {
mkp.yield 'Some element that has a '
strong 'child element'
mkp.yield ' which seems pretty basic.'
}

生产

<p>Some element that has a <strong>child element</strong> which seems pretty basic.</p>

关于使用 Groovy MarkupBuilder 的 HTML,我如何优雅地混合标签和文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com