处理Groovy标记Teamplate Engine中包含冒号的标签

时间:2019-06-21 13:02:35

标签: templates groovy

我想使用Groovy标记模板引擎,以便最终结果如下:

<ac:structured-macro ac:macro-id="cxf02" ac:name="warning" ac:schema-version="1">ERROR</ac:structured-macro>

我正在运行的基本代码如下:

TemplateConfiguration config = new TemplateConfiguration()
MarkupTemplateEngine engine = new MarkupTemplateEngine(config)
Template template = engine.createTemplate("""
<!-- I don't know what to put here -->
    """)
Map<String, Object> model = new HashMap<>()                      
Writable output = template.make(model)
println(output)

我猜冒号和破折号应该被转义,或者类似的东西。 我在groovy文档中找不到答案。

1 个答案:

答案 0 :(得分:0)

抱歉,我在这里发布问题后就找到了答案:

只需在标签上加上“”即可,因此模板应为

"ac:structured-macro"("ac:macro-id":"cxf02", "ac:name":"warning", "ac:schema-version":"1", "ERROR")
相关问题