Reputation: 12930
Any one knows how to pass variables {var}
into [source]
blocks and example blocks (with ====
) in Asciidoc?
I have tried the following
:country: France
:city: Shanghai
[source]
----
print("{country} is a country")
print("{city} is a city")
----
.Example
====
{country} is a country +
{city} is a city
====
.Example with better alignment
====
{country} is a country
{city} is a city
====
But this is what I get:
Actually the first "example" is working but it is not the ideal solution because:
+
at the end of each lineLooking forward your inputs. Thanks in advance!
Upvotes: 9
Views: 5389
Reputation: 2967
As described here you need to switch on attribute replacement in code blocks. You can achieve it with [subs="attributes"]
complete example should look something like:
[source, subs="attributes"]
----
print("{country} is a country")
print("{city} is a city")
----
.Example with better alignment
====
[subs="attributes"]
{country} is a country
{city} is a city
====
Upvotes: 11