Login  Register

Re: How to override a variable for a block?

Posted by wolandscat on Jan 30, 2019; 7:59pm
URL: https://discuss.asciidoctor.org/How-to-override-a-variable-for-a-block-tp6693p6695.html

Dan,
thanks for looking. It doesn't work - well, what you said undoubtedly does work, but the problem is that the variable in the para is {rm_common} which is a long path, and defined in terms of other variables, including {rm_release}, which is the variable that can take a value like 'latest', 'Release-1.2.3' etc.

So by the time processing arrives at the para in question, it has already done an 'include' on the file containing the def of {rm_common}, and it (I presume) evaluates it right then, using whatever the value is for included vars like {rm_release}. So when it gets to my para, it already has a value for {rm_common}, so it won't re-evaluate with an over-ridden value for {rm_release}.

So the following won't do anything interesting at all (and it doesn't):

:rm_release: latest
xxxxxxxxx xxxxxx xxxxxxxxx {rm_common} xxxxxxx xxxxx

The only way to fix this would be if a dynamic re-evaluation of a variable's original definition could be forced, but I don't think that is possible. So I'll need to find another solution.

- thomas