Substitution within intaQt Configuration Files¶
HOCON substitution functionality allows for referring to parts of a configuration tree. This is done by defining a value that should be substituted with a value from another configuration block. A path expression states from which block the value will be substituted and the variable that holds the value.
Additionally, if substituting from another configuration file that is not read by intaQt at startup, an include
statement must be added that points to the relative or absolute path of the configuration file.
Syntax
1 2 3 4 5 6 7 8 9 | // Substitutes values from configuration files read at startup <targetVariable Name> : ${<fromBlock Name>.<substitutionVariable Name>} ... } // Substitutes values from configuration files not read at startup include <filePath String> <targetVariable Name> : ${<fromBlock Name>.<substitutionVariable Name>} ... } |
Parameters
-
filePath - The path to file containing the substitution value
-
targetVariable - The name assigned to the variable that holds the substitution
-
fromBlock - The block contains the value to be used for the substitution
-
substitutionVariable - The name of the variable whose value will used for the substitution
In the example below, "value1"
is hardcoded into block1
. All other values are substitutions:
-
name2
references from within the same block and will resolve to"value1"
. -
name3
references from a different block within the same file and will resolve to"value_a"
. -
name4
references from another configuration file that was already loaded during startup, so noinclude
statement is needed. It will resolve to"value_b"
. -
name5
references another configuration file that was not loaded during startup, so theinclude
statement is needed. Its relative path../otherFolder/File3.conf
is specified aboveblock1
. It will resolve to"value_c"
.
Example
1 2 3 4 5 6 7 8 9 10 11 12 | include "../otherFolder/File3.conf" block1 = { name1 : "value1" name2 : ${block1.name1} name3 : ${block2.a} name4 : ${block3.b} name5 : ${block4.c} } block2 = { a = "value_a" } |
Block from another configuration file that was loaded during start up. A value from block3
is substituted in block1
:
1 2 3 | block3 = { b = "value_b" } |
Block from another configuration file that was not loaded during start up. A value from block4
is substituted in block1
. Because this file is not loaded at startup, its path was specified above block1
.
1 2 3 | block4 = { c = "value_c" } |