Login  Register

Counters and ifeval

Posted by halol on Jun 30, 2021; 4:32pm
URL: https://discuss.asciidoctor.org/Counters-and-ifeval-tp8667.html

Hello,

I am having an issue with counters and using them in ifeval directives:

Given the file:

{counter2:test}

The value of my counter is now {test}

// ifeval::[{test} > 1]
// The value of my counter is now {test}
// endif::[]
// => Leads to error Failed to load AsciiDoc document - undefined method `>' for nil:NilClass

ifeval::[{counter:newtest} == 1]
The value of my new counter is now {newtest}
endif::[]

The output produced is:
The value of my counter is now 1

The value of my new counter is now {newtest}

1. The first ifeval (commented out) causes an error and cannot be used at all (presumably because the counter defined beforehand is null in ifeval).
2. In the second case, the counter defined in the ifeval directive cannot be used elsewhere.

Am I doing something wrong?

Using:
asciidoctor -version
Asciidoctor 2.0.15 [https://asciidoctor.org]
On Fedora 34.