Re: If...then...else...endif -- and...or
Posted by
David Jencks on
Feb 14, 2020; 1:53am
URL: https://discuss.asciidoctor.org/If-then-else-endif-and-or-tp7645p7646.html
I didn’t try this, but I’d expect something like this might work:
ifeval::["{myvar}" == “blue”]
:myvarblue: yes
endif::[]
feval::["{myvar}" == “red”]
:myvarred: yes
endif::[]
:myvarblueorred: {myvarblue}{myvarred}
ifeval::[ “{myvarblueorred}” != “” ]
This is for categories that are blue or red.
endif::[]
ifeval::[ “{myvarblueorred}” ==“” ]
This is for categories that are neither blue nor red
endif::[]
“AND” could be done similarly (e..g == ‘yeses”)
At this point I have no opinion on whether your suggestion might be a good idea or not, but there might be a slightly less inconvenient workaround available now.
david jencks
On Feb 13, 2020, at 4:54 PM, 1marc1 [via Asciidoctor :: Discussion] <
[hidden email]> wrote:
Hi Team,
I am not sure how difficult it would be to implement, but it would be very useful to have the ability to do something like this:
:myvar: blue
ifeval::[ "{myvar}" == "blue" OR "{myvar}" == "red" ]
This is for categories that are blue or red.
else::[]
This is for categories that are not blue or red
endif::[]
At the moment, I believe the only way to achieve the above is by doing:
:myvar: blue
ifeval::[ "{myvar}" == "blue" ]
This is for categories that are blue or red.
endif::[]
ifeval::[ "{myvar}" == "red" ]
This is for categories that are blue or red.
endif::[]
ifeval::[ "{myvar}" != "blue" ]
ifeval::[ "{myvar}" != "red" ]
This is for categories that are not blue.
endif::[]
endif::[]
Marc