Usage of variables in theme

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Usage of variables in theme

1marc1
Hi Team,

Here is a question about the usage of variables inside the theme file.

I would like to accomplish the following: depending on a variable defined inside a document, chose a specific background image for my title page.

For example, my .adoc file contains ":location: Sydney"
And my Theme file contains: title_page_background_image: image:/data/front_page_{location}.png[]

I was expecting that "front_page_{location}.png" would get substituted to "front_page_Sydney.png". However, in practice this does not happen. NOTE: this does work for the "include::" directive inside an .adoc file.

I also had a look at using a custom variable inside the theme file. Along the lines of:

setlocation: {location}
title_page_background_image: image:/data/front_page_$setlocation.png[]

Unfortunately, this doesn't work either. It does work if I do "setlocation: Sydney"; but that defeats the purpose.

Is this a current limitation of the software? Any ideas and suggestions are welcome.

Marc.
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

mojavelinux
Administrator
I'm assuming you're talking about the theme file for Asciidoctor PDF. While Asciidoctor PDF does have support for variables, those variables must be defined in the theme file itself. The theme file cannot currently reference AsciiDoc document attributes (such as those defined in the document or via the API or CLI).

Here's information about the variables currently work.


Cheers,

-Dan

On Mon, Apr 23, 2018 at 2:51 PM, 1marc1 [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi Team,

Here is a question about the usage of variables inside the theme file.

I would like to accomplish the following: depending on a variable defined inside a document, chose a specific background image for my title page.

For example, my .adoc file contains ":location: Sydney"
And my Theme file contains: title_page_background_image: image:/data/front_page_{location}.png[]

I was expecting that "front_page_{location}.png" would get substituted to "front_page_Sydney.png". However, in practice this does not happen. NOTE: this does work for the "include::" directive inside an .adoc file.

I also had a look at using a custom variable inside the theme file. Along the lines of:

setlocation: {location}
title_page_background_image: image:/data/front_page_$setlocation.png[]

Unfortunately, this doesn't work either. It does work if I do "setlocation: Sydney"; but that defeats the purpose.

Is this a current limitation of the software? Any ideas and suggestions are welcome.

Marc.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Usage-of-variables-in-theme-tp6270.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

1marc1
Dan,

Thanks for your quick reply. I am indeed talking about the theme file used by asciidoctor-pdf.

The theme file does seem to be able to reference AsciiDoc document attributes defined in the document.

For example, I am currently successfully using:

page_recto_left_content: '{project_name}'
page_verso_right_content: '{project_name}'

...whereby :project_name: is defined inside the document itself.

Marc.
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

mojavelinux
Administrator
That's the one exception. The reason is, we actually treat the content fields as part of the AsciiDoc document.


On Mon, Apr 23, 2018 at 5:28 PM, 1marc1 [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Dan,

Thanks for your quick reply. I am indeed talking about the theme file used by asciidoctor-pdf.

The theme file does seem to be able to reference AsciiDoc document attributes defined in the document.

For example, I am currently successfully using:

page_recto_left_content: '{project_name}'
page_verso_right_content: '{project_name}'

...whereby :project_name: is defined inside the document itself.

Marc.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Usage-of-variables-in-theme-tp6270p6273.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

1marc1
Dan,

That makes sense. Thank you for explaining.

Marc.
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

ascju
In reply to this post by mojavelinux
Anyone know if support for variable references for asciidoctor pdf is planned?
Dynamically creating my documentations header/footer information with version and revision number, release date etc. would make my life so much easier...
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

mojavelinux
Administrator
You can use AsciiDoc attribute references in the header and footer content (for example, {revnumber}). This content is subject to normal substitutions, just like in the AsciiDoc document itself.


On Tue, May 15, 2018 at 2:29 PM, ascju [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Anyone know if support for variable references for asciidoctor pdf is planned?
Dynamically creating my documentations header/footer information with version and revision number, release date etc. would make my life so much easier...


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Usage-of-variables-in-theme-tp6270p6329.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

ascju
Wow ... thanks for the super-fast reply.
I did miss this part of the pdf documentation (which by the way is really great!). Works like a charm. I'm happy!
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Usage of variables in theme

mojavelinux
Administrator
I'm glad to hear that! Good luck!

-Dan

On Tue, May 15, 2018 at 3:42 PM, ascju [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Wow ... thanks for the super-fast reply.
I did miss this part of the pdf documentation (which by the way is really great!). Works like a charm. I'm happy!
Thanks!


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Usage-of-variables-in-theme-tp6270p6331.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux