Reputation: 1
I want to dynamically display a certain server status in an asciidoc (rendered in gitlab)
Something like
:status-server-1: 1
ifeval::[{status-server-1} == 1]
image::green_dot.png[green_dot,20,20]
endif::[]
Now how to dynamically set the attribute?
Is there a way the change the attribute with javascript or similar?
Upvotes: 0
Views: 379
Reputation: 4521
asciidoctor
doesn't process JavaScript. It transforms Asciidoc markup to HTML (or other formats). JavaScript only comes into play when the resulting HTML is loaded into a browser.
It would be possible to run a JavaScript program before you run asciidoctor
to determine the server status and set an environment variable that could then be used during asciidoctor
processing. For example:
STATUS=`node status.js`; asciidoctor -a server_status="$STATUS" <file.adoc>
A different approach would be to use Docinfo files to add custom JS or CSS. Custom JS would allow you to perform an XHR request to discover the current server status and then adjust the classes/styles/images needed to reflect that status.
Upvotes: 1