Asciidoctor: Can I use a variable in the code block? How?

Created on 2 May 2016  路  5Comments  路  Source: asciidoctor/asciidoctor

I define a variable as follows:

:var_gradle_version: gradle-2.13-bin.zip

I want to use the variable in a code block. The document content is as follows:

.Gradle links
----
distributionUrl=file\:///home/diguage/develop/tools/{var_gradle_version}
----

I try it. But it does not work.

Can I use the variable in the code block? How?

Thanks a lot.

Most helpful comment

Hi,

Source blocks do by default not apply attributes substitutions like described at the bottom of http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary
(Source blocks use the verbatim substitutions.)

You want to try this to also apply attribute substitutions:

[subs="attributes"]
----
distributionUrl=file\:///home/diguage/develop/tools/{var_gradle_version}
----

Cheers
Robert

All 5 comments

Hi,

Source blocks do by default not apply attributes substitutions like described at the bottom of http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary
(Source blocks use the verbatim substitutions.)

You want to try this to also apply attribute substitutions:

[subs="attributes"]
----
distributionUrl=file\:///home/diguage/develop/tools/{var_gradle_version}
----

Cheers
Robert

@robertpanzer This is OK. Thanks a lot.

[subs="attributes"]

Almost right. You either need to use incremental subs:

[subs=attributes+]

or you need to provide all the other subs you want to keep

[subs="attributes,verbatim"]

The incremental subs are preferred.

@mojavelinux
First, AsciiDoctor is a awesome project. Thank you. Thank all the people who contribute to the project.

You show me some subs. I knew the subs. But, Where can I find all the subs and the describution?

Was this page helpful?
0 / 5 - 0 ratings