I need to access a value of a Velocity template's variable named:
$myFeature.enabled
Mind the dot within the name. It is defined in the code as:
myFeature.enabled=true
The problem is that, when I want to get the value of that variable withing html context with the following expression:
'${myFeature.enabled}'
it is not resolved and just gives:
"${myFeature.enabled}"
I tried to escape the dot with \ or change apostrophes to " but without luck.
Changing the name of the variable to a one without a dot is not an easy option for various reasons, so please suggest any other solutions.
The answer is as simple as:
Velocity variable naming: does not allow dots within variable
Also here:
To use a $SINGLE.VARIABLE.IDENTIFIER.WITH.DOTS no backslash is required. The engine will not treat such expression as a variable to be processed because a Velocity variable cannot contain dots according to the Velocity variable notation.
Links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With