Asciidoctor 参数化模板

Asciidoctor parametetrized template

我正在使用 asciidoctor 和 asciidoctor-maven-plugin。在我的文档(实际上是文档)中,我有一个块重复了很多次。有什么办法可以包含参数吗?

我想要的伪代码,找不到怎么写:

模板:

=== HTTP request
include::{snippets}/{variable}/http-request.adoc[]
=== HTTP response
include::{snippets}/{variable}/http-response.adoc[]

用法

include template[variable=customer]

谢谢。

我认为你可以redefine attributes。有了这棵树:

Folder
|   main.adoc
|   template.adoc
|
\---code
    +---first
    |       http-request.adoc
    |       http-response.adoc
    |
    \---second
            http-request.adoc
            http-response.adoc

我的 main.adoc 文件如下所示:

:snippets: code

== First Chapter

:variable: first

include::template.adoc[]

== Second Chapter

:variable: second

include::template.adoc[]

== End

This is the end.

前面的例子可行,但我感觉这不是你想要的。

如果您正在寻找宏示例,请查看此 Maven 和 java 示例:java-extension-example.