【发布时间】:2014-02-07 22:29:42
【问题描述】:
希望使用 groovy 为 Asciidoctor 标记编写 groovy.text.Template。到目前为止:
//-----------------------------------
public class AsciidocTemplate implements groovy.text.Template
{
boolean includeHeaderFooter = true;
Asciidoctor asciidoctor = create();
org.asciidoctor.Options asciidoctorJOptions=["backend": "html","header_footer":includeHeaderFooter]
def payload="";
Map binding = [:]
public AsciidocTemplate()
{
} // end of constructor
public AsciidocTemplate(def payload)
{
this.payload = payload;
} // end of constructor
// use doctor to transform the template
public Writable process()
{
def output = asciidoctor.render(this.payload, asciidoctorJOptions);
Writer ou = output;
return ou;
} // end of make
Writable make()
{
return process(); //output as Writable;
} // end of make
// -----------------------------------
render() 返回一个字符串,我们如何将该字符串转换为实现 Writable 接口的对象,我只是不明白。也看不到如何使用/读取/存储返回的“可写”对象:-P
【问题讨论】:
标签: java groovy interface writable