Passing parameters to template files in asciidoc
Asked Answered
H

1

7

I'm generating asciidoc snippets using spring rest docs.

I can include the generated snippets in my doc page. However, I want to define the structure of each secion once in a seperate adoc file, and have a single line for each of those in my index file.

Currently my index.adoc file looks like this:

= My Http Api Docs

= GET /units/:id

== Path Parameters
include::{snippets}/units/get/path-parameters.adoc[]

== Response Fields
include::{snippets}/units/get/response-fields.adoc[]

I want it to be like this instead

index.adoc

= My Http Api Docs

usemytemplates::mytemplate.adoc[method='get', url='units', desc='/units/:id']

mytemplate.adoc

= {method} {desc}

== Path Parameters
include::{snippets}/{url}/{method}/path-parameters.adoc[]

== Response Fields
include::{snippets}/{url}/{method}/response-fields.adoc[]

Anyone know how something like this can be done?

Humble answered 18/5, 2016 at 23:20 Comment(0)
H
11

I was able to solve this by using the substitution syntax before each include statement.

My index.adoc file looks like this and it works:

:method: get
:url: units
:desc: /utils/:id
include::mytemplate.adoc[]

:method: get
:url: members
:desc: /members/:id
include::mytemplate.adoc[]
Humble answered 19/5, 2016 at 6:43 Comment(1)
Here is an example in the off. doc: asciidoctor.org/docs/user-manual/#include-multiplePolyadelphous

© 2022 - 2024 — McMap. All rights reserved.