1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 11:38:30 +00:00

fix cyclic ref between var and dvar for #252

This commit is contained in:
deadc0de6
2020-08-25 08:14:08 +02:00
parent 393bd3afe4
commit 09aac991a4
3 changed files with 48 additions and 5 deletions

View File

@@ -44,10 +44,31 @@ Only the higher layer is accessible to other classes of dotdrop.
**Rules**
* `dynvariables` are executed in their own config file
* since `variables` and `dynvariables` are templated before the `dynvariables`
are executed, this means that `dynvariables` can safely reference `variables` however
`variables` referencing `dynvariables` will result with the none executed value of the
referenced `dynvariables` (see examples below)
* a `dynvariables` can reference a `variables` however the opposite is not possible
* profile cannot include profiles defined above in the import tree
* config files do not have access to variables
defined above in the import tree
This will result with `var0 = "echo test"` and not `var0 = test`
```yaml
variables:
var0: "{{@@ dvar4 @@}}"
dynvariables:
dvar0: "echo test"
```
This will result with `dvar0 = "test"`
```yaml
variables:
var0: "test"
dynvariables:
dvar0: "echo {{@@ var0 @@}}"
```
**Precedence**
* `dynvariables` > `variables`
@@ -100,9 +121,9 @@ How variables are resolved (through jinja2's
templating) in the config file.
* resolve main config file variables
* `variables` and `dynvariables` are recursively templated
* merge `variables` and `dynvariables` (allowing cycling reference)
* recursively template merged `variables` and `dynvariables`
* `dynvariables` are executed
* both `variables` and `dynvariables` are merged
* profile's `variables` and `dynvariables` are merged
* resolve *included* entries (see below)
* paths and entries are templated