11

Suppose I have 2 YAML files:

1) application.yml

en:
  variable: "Hello World"

2) user.yml

en:
  variable: <Here I want to get value from application.yml -> "Hello World" >

At first I though that I might use referencing:

1) application.yml

en:
  variable: &variable "Hello World"

2) user.yml

en:
  variable: *variable

But turned out that it is only possible for items declared in one file. Is there any way I can get the value from the variable defined in application.yml ?

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Dmitri
  • 2,451
  • 6
  • 35
  • 55

1 Answers1

9

So the only way is to create another, third file that would hold shared values. Or to use the value from "application.yml".

YAML references are intra-file.

You could also have a preprocessing step where you merge YAML files.

In *nix shell:

cat foo.yaml bar.yaml > baz.yaml

In Powershell:

cat foo.yaml, bar.yaml > baz.yaml

In batch:

type foo.yaml bar.yaml > baz.yaml

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265