希望用 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