jbake

Accessing custom jbake confing properties in asciidoc


After some time I spent staring at the jbake code, I figured out that if I declare my own property in jbake.properties :

...
foo=bar
...

I can reuse that in files that go through a template engine by referencing it as ${config.foo}. I'd like to have this substitution working also on the content lvl, i.e. for files written in asciidoc, living inside the content directory.

Is there any non-trivial way to achieve it? How can I make the templating engine to proccess the result of asciidoc parses engine, or make it running it before the asciidoctor?


Solution

  • I found the answer myself. To use the property substitution in asciidoc files, add following to the jbake.properties:

    ...
    asciidoctor.attributes.export=true
    foo=world
    ...
    

    and reference the variable in aFile.adoc this way:

    Hello {foo}!