Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML reference another variable in another file

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 ?

like image 404
Dmitri Avatar asked Mar 25 '14 15:03

Dmitri


1 Answers

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

  • Look Ma, No Tags!

  • Powershell cmdlets: get-content

  • cat

  • COPY Concatenates Files Based on Command Syntax

like image 57
6 revs Avatar answered Nov 03 '22 11:11

6 revs