Page 1 of 1

Snippet variables in attribute values - a bug?

Posted: Tue Aug 01, 2017 1:22 pm
by FrankyT
I don't know if anyone can help... I'm using Flare's new snippet variables feature to alter certain words in the snippet according to the context in different topics. It works well with simple text-based variables, but when I try to use a variable in an attribute for a cross-reference target -

Code: Select all

<MadCap:xref href="mcvariable:CustomVariables.xrefTarget"><span style="color: #0077c8;" class="mcFormatColor"><u>Making a Wardrobe</u></span></MadCap:xref>
- it doesn't work. The default value of the variable CustomVariables.xrefTarget is always used, even when the snippet has an override in its snippet variables.

I.e. if the default value of CustomVariables.xrefTarget is "#making_a_wardrobe", and I override it in a snippet import with "#making_a_chair" -
sv.png
- the override is ignored, and the default variable value is used in the output. Since the default value points to a non-existent anchor, clicking the link just takes you to the top of the page (because the first character is #, i.e. the current page, and nothing after that makes sense to the browser). The link in the output looks like this:

Code: Select all

<p>See <a href="#making_a_wardrobe" class="MCXref xref" data-mc-variable-override="">Making a Wardrobe</a>.</p>
Note that the data-mc-variable-override attribute is empty, and surely it shouldn't be.

I'm guessing that this is a bug that got overlooked because this is, admittedly, a bit of an edge-case scenario. However, if anyone can think of a way around it, I'd be grateful, as I would rather not go back to using complex condition tag selectors to make dynamic snippets, which I used to do and eventually gave up on because it was harder work than copying and pasting.

Thanks,

Franky

Re: Snippet variables in attribute values - a bug?

Posted: Wed Aug 02, 2017 3:52 am
by FrankyT
I've solved the problem. It isn't documented and I deduced it from Flare's behaviour in other situations.

The correct format for including a variable inside a tag (as opposed to plain text) is [%=VariableSet.VariableName%]. So my link now looks like this:

Code: Select all

<MadCap:xref href="[%=CustomVariables.xrefTarget%]"><span style="color: #0077c8;" class="mcFormatColor"><u>Making a Wardrobe</u></span></MadCap:xref>
This is overridden by the snippet variable override, and the output link is correct:
mac.PNG
(Incidentally, my previous attempt at using mcvariable: to reference a variable from an attribute was derived from another post in these forums. I don't know where the author got it (I can't find it in the Flare documentation) - but anyway, it doesn't seem to work.)