How to define variables globally?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to define variables globally?

Carl
Hi, I am new to AsciiDoc.

I have defined this variable (attribute) in the document header of each help topic:

:prodName: Our Product Name

This way I can reference our product name using {prodName}. However, each help topic is in its own *.adoc file. Thus, I will have hundreds of adoc files when I'm done. This method of defining in each document header is not sustainable! Is there a place where I can define these global variables just once, then reference them in each topic?
Reply | Threaded
Open this post in threaded view
|

Re: How to define variables globally?

ctargett
How are you going to convert your pages to whatever format you're going to publish? The answer very much depends on that, since that's what will need to know your global values.

If you're using the Asciidoctor CLI directly, you can declare the attribute value when you run it (see https://docs.asciidoctor.org/asciidoctor/latest/cli/options/#document-settings).

If you're going to integrate with something else and use the API, attribute values can also be set that way (https://docs.asciidoctor.org/asciidoctor/latest/api/options/).

In my current project, we're using Jekyll and we declare the attribute values in Jekyll's _config.yml.

We used to use the asciidoctor-ant integration and we just declared the global values in Ant's build.xml. In a different project, I've also used Gradle to call Asciidoctor directly and was able to use a gradle.properties file to declare the global values for several custom attributes we used at the time.

It's not 100% straightforward with Ant and Gradle, but it's definitely possible.
Reply | Threaded
Open this post in threaded view
|

Re: How to define variables globally?

abelsromero
Thanks a lot for your insight. Just mention we continued the conversation in Zulip https://asciidoctor.zulipchat.com/#narrow/stream/279642-users/topic/Where.20to.20place.20variables.20globally.3F.

@Carl if you could delete this thread that would help others follow the conversation.